|
1 | 1 | /* eslint-disable no-console */ |
2 | 2 | import type { AsyncLocalStorage } from 'node:async_hooks'; |
3 | 3 | import { spawnSync } from 'node:child_process'; |
4 | | -import * as fs from 'node:fs'; |
5 | 4 | import * as os from 'node:os'; |
6 | 5 | import * as path from 'node:path'; |
7 | 6 | import { env, versions } from 'node:process'; |
8 | 7 | import { threadId } from 'node:worker_threads'; |
9 | 8 | import * as libc from 'detect-libc'; |
10 | 9 | import { getAbi } from 'node-abi'; |
| 10 | +import { copyBinary } from './copy-binary'; |
11 | 11 |
|
12 | 12 | const stdlib = libc.familySync(); |
13 | 13 | const platform = process.env['BUILD_PLATFORM'] || os.platform(); |
@@ -56,33 +56,6 @@ interface Native { |
56 | 56 | getThreadsLastSeen(): Record<string, number>; |
57 | 57 | } |
58 | 58 |
|
59 | | -/** |
60 | | - * Copies the compiled binary from the build directory to the lib directory with the correct name based on the current platform and Node version. |
61 | | - * |
62 | | - * @hidden We only use this for copying the binary after building, it is not intended to be used by end users. |
63 | | - */ |
64 | | -export function copyBinary(): void { |
65 | | - const build = path.resolve(__dirname, '..', 'lib'); |
66 | | - if (!fs.existsSync(build)) { |
67 | | - fs.mkdirSync(build, { recursive: true }); |
68 | | - } |
69 | | - |
70 | | - if (!fs.existsSync(source)) { |
71 | | - console.log('Source file does not exist:', source); |
72 | | - process.exit(1); |
73 | | - } else { |
74 | | - if (fs.existsSync(target)) { |
75 | | - console.log('Target file already exists, overwriting it'); |
76 | | - fs.unlinkSync(target); |
77 | | - } |
78 | | - console.log('Copying', source, 'to', target); |
79 | | - fs.copyFileSync(source, target); |
80 | | - } |
81 | | -} |
82 | | - |
83 | | -const source = path.join(__dirname, '..', 'build', 'Release', 'stack-trace.node'); |
84 | | -const target = path.join(__dirname, '..', 'lib', `stack-trace-${identifier}.node`); |
85 | | - |
86 | 59 | function clean(err: Buffer): string { |
87 | 60 | return err.toString().trim(); |
88 | 61 | } |
|
0 commit comments