Skip to content
This repository was archived by the owner on Jan 13, 2024. It is now read-only.

Commit dd9de59

Browse files
committed
producer: properly call "prebuild-install" if N-API is used
Bug: #1695
1 parent f81a08c commit dd9de59

File tree

1 file changed

+17
-12
lines changed

1 file changed

+17
-12
lines changed

lib/producer.ts

+17-12
Original file line numberDiff line numberDiff line change
@@ -221,19 +221,24 @@ function nativePrebuildInstall(target: Target, nodeFile: string) {
221221
fs.copyFileSync(nodeFile, `${nodeFile}.bak`);
222222
}
223223

224+
const napiVersions = JSON.parse(
225+
fs.readFileSync(path.join(dir, 'package.json'), { encoding: 'utf-8' })
226+
)?.binary?.napi_versions;
227+
228+
const options = [
229+
'--platform',
230+
platform[target.platform],
231+
'--arch',
232+
target.arch,
233+
];
234+
235+
if (napiVersions == null) {
236+
// TODO: consider target node version and supported n-api version
237+
options.push('--target', nodeVersion);
238+
}
239+
224240
// run prebuild
225-
execFileSync(
226-
prebuildInstall,
227-
[
228-
'--target',
229-
nodeVersion,
230-
'--platform',
231-
platform[target.platform],
232-
'--arch',
233-
target.arch,
234-
],
235-
{ cwd: dir }
236-
);
241+
execFileSync(prebuildInstall, options, { cwd: dir });
237242

238243
// move the prebuild to a new name with a platform/version extension
239244
fs.copyFileSync(nodeFile, nativeFile);

0 commit comments

Comments
 (0)