Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"sentry"
],
"scripts": {
"install": "node scripts/check-build.mjs",
"lint": "yarn lint:eslint && yarn lint:clang",
"lint:eslint": "eslint . --format stylish",
"lint:clang": "node scripts/clang-format.mjs",
Expand All @@ -25,16 +24,16 @@
"fix:clang": "node scripts/clang-format.mjs --fix",
"build": "yarn clean && yarn build:lib && yarn build:bindings:configure && yarn build:bindings",
"build:lib": "tsc",
"build:copy-binary": "node -e \"const { copyBinary } = require('./lib/copy-binary.js'); copyBinary();\"",
"build:bindings:configure": "node-gyp configure",
"build:bindings:configure:arm64": "node-gyp configure --arch=arm64 --target_arch=arm64",
"build:bindings": "node-gyp build && node scripts/copy-target.mjs",
"build:bindings:arm64": "node-gyp build --arch=arm64 && node scripts/copy-target.mjs",
"build:bindings": "yarn build:lib && node-gyp build && yarn build:copy-binary",
"build:bindings:arm64": "yarn build:lib && node-gyp build --arch=arm64 && yarn build:copy-binary",
"build:tarball": "npm pack",
"clean": "node-gyp clean && rm -rf lib && rm -rf build && rm -f *.tgz",
"test": "yarn test:install && yarn test:prepare && vitest run --poolOptions.forks.singleFork --silent=false --disable-console-intercept",
"test:prepare": "node ./test/prepare.mjs",
"test:install": "cross-env ALWAYS_THROW=true yarn install"
"test": "node ./test/prepare.mjs && vitest run --poolOptions.forks.singleFork --silent=false --disable-console-intercept"
},
"gypfile": false,
"engines": {
"node": ">=18"
},
Expand Down
18 changes: 0 additions & 18 deletions scripts/binaries.mjs

This file was deleted.

55 changes: 0 additions & 55 deletions scripts/check-build.mjs

This file was deleted.

26 changes: 0 additions & 26 deletions scripts/copy-target.mjs

This file was deleted.

31 changes: 31 additions & 0 deletions src/copy-binary.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* eslint-disable no-console */
import * as fs from 'node:fs';
import * as path from 'node:path';
import { identifier } from './identifier';

const source = path.join(__dirname, '..', 'build', 'Release', 'stack-trace.node');
const target = path.join(__dirname, '..', 'lib', `stack-trace-${identifier}.node`);

/**
* Copies the compiled binary from the build directory to the lib directory with the correct name based on the current platform and Node version.
*
* @hidden We only use this for copying the binary after building, it is not intended to be used by end users.
*/
export function copyBinary(): void {
const build = path.resolve(__dirname, '..', 'lib');
if (!fs.existsSync(build)) {
fs.mkdirSync(build, { recursive: true });
}

if (!fs.existsSync(source)) {
console.log('Source file does not exist:', source);
process.exit(1);
} else {
if (fs.existsSync(target)) {
console.log('Target file already exists, overwriting it');
fs.unlinkSync(target);
}
console.log('Copying', source, 'to', target);
fs.copyFileSync(source, target);
}
}
12 changes: 12 additions & 0 deletions src/identifier.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

import * as os from 'node:os';
import { versions } from 'node:process';
import * as libc from 'detect-libc';
import { getAbi } from 'node-abi';

const stdlib = libc.familySync();
const platform = process.env['BUILD_PLATFORM'] || os.platform();
const arch = process.env['BUILD_ARCH'] || os.arch();
const abi = getAbi(versions.node, 'node');

export const identifier = [platform, arch, stdlib, abi].filter(c => c !== undefined && c !== null).join('-');
Loading
Loading