Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

All phony to take an array of targets #9

Merged
merged 1 commit into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ninjutsu-build/core",
"version": "0.8.3",
"version": "0.8.5",
"description": "Easily create ninja build files with this TypeScript library (https://ninja-build.org/)",
"author": "Elliot Goodrich",
"engines": {
Expand Down
8 changes: 8 additions & 0 deletions packages/core/src/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,18 @@ test("phony rule", () => {
const out2: "my:: alia$ !" = phony({ out: "my:: alia$ !", in: "file$ .txt" });
assert.equal(out2, "my:: alia$ !");

const out3: "all" = phony({ out: "all", in: ["in1", "in2"] });
assert.equal(out3, "all");

const out4: "none" = phony({ out: "none", in: [] });
assert.equal(out4, "none");

assert.equal(
ninja.output,
`build alias: phony file.txt
build my$:$:$ alia$$ !: phony file$$ .txt
build all: phony in1 in2
build none: phony
`,
);
});
Expand Down
14 changes: 10 additions & 4 deletions packages/core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,13 +398,19 @@ export class NinjaBuilder {
* ninja.default(foo, mybar);
* ```
*/
get phony(): <O extends string>(args: { out: O; in: string }) => O {
return <O extends string>(args: { out: O; in: string }): O => {
get phony(): <O extends string>(args: {
out: O;
in: string | readonly string[];
}) => O {
return <O extends string>(args: {
out: O;
in: string | readonly string[];
}): O => {
this.output +=
"build " +
escapePath(args.out) +
": phony " +
escapePath(args.in) +
": phony" +
concatPaths(" ", args.in) +
"\n";
return args.out;
};
Expand Down
Loading