Skip to content

Commit

Permalink
Merge pull request #1641 from kuzudb/nodejs-win-ci-fix
Browse files Browse the repository at this point in the history
Fix Node.js CI build on Windows
  • Loading branch information
mewim committed Jun 6, 2023
2 parents dbb2552 + 449df26 commit 4300120
Showing 1 changed file with 29 additions and 8 deletions.
37 changes: 29 additions & 8 deletions tools/nodejs_api/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,37 @@ if (process.platform === "darwin") {
}
}

const execArgs = {
cwd: path.join(__dirname, "kuzu-source"),
stdio: "inherit",
};

execArgs.env = process.platform === "win32" ? process.env : env;
if (process.platform === "win32") {
// The `rc` package conflicts with the rc command (resource compiler) on
// Windows. This causes the build to fail. This is a workaround which removes
// all the environment variables added by npm.
const pathEnv = process.env["Path"];
const pathSplit = pathEnv.split(";").filter((path) => {
const pathLower = path.toLowerCase();
return !pathLower.includes("node_modules");
});
env["Path"] = pathSplit.join(";");
console.log(
"The PATH environment variable has been modified to remove any 'node_modules' directories."
);

console.log(env);
for (let key in env) {
if (
key.toLowerCase().includes("node" || key.toLowerCase().includes("npm"))
) {
delete env[key];
}
}
console.log(
"Any environment variables containing 'node' or 'npm' have been removed."
);
}

childProcess.execSync("make nodejs NUM_THREADS=" + THREADS, execArgs);
childProcess.execSync("make nodejs NUM_THREADS=" + THREADS, {
env,
cwd: path.join(__dirname, "kuzu-source"),
stdio: "inherit",
});

// Copy the built files to the package directory
const BUILT_DIR = path.join(
Expand Down

0 comments on commit 4300120

Please sign in to comment.