Skip to content

Commit

Permalink
Fix @ninjutsu-build/node args variable
Browse files Browse the repository at this point in the history
The `args` variable really should be used for command line arguments
passed to the JavaScript file rather than command line arguments for
node or v8.  node and v8 flags can now be passed with `nodeArgs`.
  • Loading branch information
elliotgoodrich committed Mar 1, 2024
1 parent bb1103c commit c0eca30
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/node/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ninjutsu-build/node",
"version": "0.8.2",
"version": "0.9.0",
"description": "A ninjutsu-build plugin to generate ninja rules to execute JavaScript with node",
"author": "Elliot Goodrich",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions packages/node/src/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ test("makeNodeRule", () => {
const out2: "out2.txt" = myNode({
out: "out2.txt",
in: "in.js",
nodeArgs: "--allow-worker",
args: "--foo",
[implicitDeps]: ["other"],
});
Expand Down
8 changes: 6 additions & 2 deletions packages/node/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ const importCode =
// we mention `node.exe` with the file extension to avoid the `winpty node` alias.
const node = platform() === "win32" ? "cmd /c node.exe" : "node";

const command = `${node} --require "${hookRequire}" --import "data:text/javascript,${importCode}" $args $in > $out`;
const testCommand = `${node} --require "${hookRequire}" --import "data:text/javascript,${importCode}" --test --test-reporter=${testReporter} --test-reporter=tap --test-reporter-destination=stderr --test-reporter-destination=$out $in`;
const command = `${node} --require "${hookRequire}" --import "data:text/javascript,${importCode}" $nodeArgs $in -- $args > $out`;
const testCommand = `${node} --require "${hookRequire}" --import "data:text/javascript,${importCode}" --test --test-reporter=${testReporter} --test-reporter=tap --test-reporter-destination=stderr --test-reporter-destination=$out $nodeArgs $in -- $args`;

/**
* Create a rule in the specified `ninja` builder with the specified `name` that will
Expand Down Expand Up @@ -61,6 +61,7 @@ export function makeNodeRule(
in: Input<string>;
out: O;
args?: string;
nodeArgs?: string;
[implicitDeps]?: string | readonly string[];
[orderOnlyDeps]?: string | readonly string[];
[implicitOut]?: string | readonly string[];
Expand All @@ -74,6 +75,7 @@ export function makeNodeRule(
depfile: "$out.depfile",
deps: "gcc",
args: "",
nodeArgs: "",
});
}

Expand Down Expand Up @@ -114,6 +116,7 @@ export function makeNodeTestRule(
in: Input<string>;
out: O;
args?: string;
nodeArgs?: string;
[implicitDeps]?: string | readonly string[];
[orderOnlyDeps]?: string | readonly string[];
[implicitOut]?: string | readonly string[];
Expand All @@ -127,5 +130,6 @@ export function makeNodeTestRule(
depfile: "$out.depfile",
deps: "gcc",
args: "",
nodeArgs: "",
});
}

0 comments on commit c0eca30

Please sign in to comment.