You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

napi-postinstall

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

napi-postinstall - npm Package Compare versions

Comparing version
0.1.0
to
0.1.1
+3
-3
lib/helpers.d.ts

@@ -5,8 +5,8 @@ import { NapiInfo, PackageJson } from './types.js';

export declare function downloadedNodePath(name: string, subpath: string): string;
export declare function getNapiInfoFromPackageJson(packageJson: PackageJson, checkVersion: true): NapiInfo;
export declare function getNapiInfoFromPackageJson(packageJson: PackageJson, checkVersion?: boolean): NapiInfo & {
version?: string;
export declare function getNapiInfoFromPackageJson(packageJson: PackageJson, checkVersion: true): NapiInfo & {
version: string;
};
export declare function getNapiInfoFromPackageJson(packageJson: PackageJson, checkVersion?: boolean): NapiInfo;
export declare function getNapiNativeTarget(): string[] | string;
export declare function getNapiNativeTargets(): string[];
export declare function getErrorMessage(err: unknown): string;

@@ -54,12 +54,15 @@ "use strict";

const targets = (_a = napi_ === null || napi_ === void 0 ? void 0 : napi_.targets) !== null && _a !== void 0 ? _a : (_b = napi_ === null || napi_ === void 0 ? void 0 : napi_.triples) === null || _b === void 0 ? void 0 : _b.additional;
if (!(targets === null || targets === void 0 ? void 0 : targets.length) || !optionalDependencies) {
throw new Error(`No \`napi.targets\` nor \`optionalDependencies\` field found in \`${name}\`'s \`package.json\`. Please ensure the package is built with NAPI support.`);
if (!(targets === null || targets === void 0 ? void 0 : targets.length)) {
throw new Error(`No \`napi.targets\` nor \`napi.triples.additional\` field found in \`${name}\`'s \`package.json\`. Please ensure the package is built with NAPI support.`);
}
const napi = napi_;
(_c = napi.binaryName) !== null && _c !== void 0 ? _c : (napi.binaryName = napi.name);
(_d = napi.packageName) !== null && _d !== void 0 ? _d : (napi.packageName = (_f = (_e = napi.package) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : name);
napi.targets = targets;
if (!optionalDependencies) {
return { napi };
}
let version;
for (const target of targets) {
const { platformArchABI } = (0, target_js_1.parseTriple)(target);
(_c = napi.binaryName) !== null && _c !== void 0 ? _c : (napi.binaryName = napi.name);
(_d = napi.packageName) !== null && _d !== void 0 ? _d : (napi.packageName = (_f = (_e = napi.package) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : name);
const pkg = `${napi.packageName}-${platformArchABI}`;

@@ -66,0 +69,0 @@ const packageVersion = optionalDependencies[pkg];

@@ -107,4 +107,4 @@ "use strict";

: packageNameOrPackageJson;
const { napi, version: napiVersion } = (0, helpers_js_1.getNapiInfoFromPackageJson)(packageJson, checkVersion);
const { name, version, optionalDependencies } = packageJson;
const { napi, version: napiVersion = version } = (0, helpers_js_1.getNapiInfoFromPackageJson)(packageJson, checkVersion);
if (checkVersion && version !== napiVersion) {

@@ -116,3 +116,3 @@ throw new Error(`Inconsistent package versions found for \`${name}\` v${version} vs \`${napi.packageName}\` v${napiVersion}.`);

const pkg = `${napi.packageName}-${target}`;
if (!optionalDependencies[pkg]) {
if (!(optionalDependencies === null || optionalDependencies === void 0 ? void 0 : optionalDependencies[pkg])) {
continue;

@@ -139,3 +139,3 @@ }

console.error(`${constants_js_1.LOG_PREFIX}Trying to install package "${pkg}" using npm`);
installUsingNPM(name, pkg, version, subpath, nodePath);
installUsingNPM(name, pkg, napiVersion, subpath, nodePath);
break;

@@ -146,3 +146,3 @@ }

try {
yield downloadDirectlyFromNPM(pkg, version, subpath, nodePath);
yield downloadDirectlyFromNPM(pkg, napiVersion, subpath, nodePath);
break;

@@ -149,0 +149,0 @@ }

@@ -21,3 +21,3 @@ export interface Napi {

napi: Napi;
version: string;
version?: string;
}

@@ -24,0 +24,0 @@ export interface PackageJson {

{
"name": "napi-postinstall",
"version": "0.1.0",
"version": "0.1.1",
"type": "commonjs",

@@ -5,0 +5,0 @@ "description": "The `postinstall` script helper for handling native bindings in legacy `npm` versions",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet