Skip to content

Commit

Permalink
fix(bld): maintain cwd when using managedManifest or nativeAddon (#1187)
Browse files Browse the repository at this point in the history
Fixes: #1186
  • Loading branch information
breavyn authored Aug 5, 2024
1 parent 8f4e07d commit 40223db
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/bld.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,21 +230,19 @@ const manageManifest = async ({ nwPkg, managedManifest, outDir, platform }) => {
"utf8",
);

process.chdir(
path.resolve(
outDir,
platform !== "osx"
? "package.nw"
: "nwjs.app/Contents/Resources/app.nw",
),
const cwd = path.resolve(
outDir,
platform !== "osx"
? "package.nw"
: "nwjs.app/Contents/Resources/app.nw",
);

if (manifest.packageManager.startsWith("npm")) {
child_process.execSync(`npm install`);
child_process.execSync(`npm install`, { cwd });
} else if (manifest.packageManager.startsWith("yarn")) {
child_process.execSync(`yarn install`);
child_process.execSync(`yarn install`, { cwd });
} else if (manifest.packageManager.startsWith("pnpm")) {
child_process.execSync(`pnpm install`);
child_process.execSync(`pnpm install`, { cwd });
}
};

Expand Down Expand Up @@ -420,16 +418,14 @@ const setOsxConfig = async ({ outDir, app }) => {

const buildNativeAddon = ({ cacheDir, version, platform, arch, outDir, nodeVersion }) => {
let nodePath = path.resolve(cacheDir, `node-v${version}-${platform}-${arch}`);
process.chdir(
path.resolve(
outDir,
platform !== "osx"
? "package.nw"
: "nwjs.app/Contents/Resources/app.nw",
),
const cwd = path.resolve(
outDir,
platform !== "osx"
? "package.nw"
: "nwjs.app/Contents/Resources/app.nw",
);

child_process.execSync(`node-gyp rebuild --target=${nodeVersion} --nodedir=${nodePath}`);
child_process.execSync(`node-gyp rebuild --target=${nodeVersion} --nodedir=${nodePath}`, { cwd });
};

const compress = async ({
Expand Down

0 comments on commit 40223db

Please sign in to comment.