Skip to content

Commit f20b5b9

Browse files
committed
Run publint only in the non-private packages
1 parent 14e7452 commit f20b5b9

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dev": "tsc --build --watch",
2424
"lint": "eslint .",
2525
"depcheck": "node scripts/depcheck.ts",
26-
"publint": "npm exec --workspaces publint",
26+
"publint": "node scripts/run-in-published.ts npx publint --strict",
2727
"prettier:check": "prettier --experimental-cli --check .",
2828
"prettier:write": "prettier --experimental-cli --write .",
2929
"test": "npm test --workspace react-native-node-api --workspace cmake-rn --workspace gyp-to-cmake --workspace node-addon-examples",

scripts/run-in-published.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import assert from "node:assert/strict";
2+
import cp from "node:child_process";
3+
4+
console.log("Run command in all non-private packages of the monorepo");
5+
6+
function getWorkspaces() {
7+
const workspaces = JSON.parse(
8+
cp.execFileSync("npm", ["query", ".workspace"], { encoding: "utf8" }),
9+
) as unknown;
10+
assert(Array.isArray(workspaces));
11+
for (const workspace of workspaces) {
12+
assert(typeof workspace === "object" && workspace !== null);
13+
}
14+
return workspaces as Record<string, unknown>[];
15+
}
16+
17+
const publishedPackagePaths = getWorkspaces()
18+
.filter((w) => !w.private)
19+
.map((p) => {
20+
assert(typeof p.path === "string");
21+
return p.path;
22+
});
23+
24+
const [, , command, ...argv] = process.argv;
25+
26+
for (const packagePath of publishedPackagePaths) {
27+
const { status } = cp.spawnSync(command, argv, {
28+
cwd: packagePath,
29+
stdio: "inherit",
30+
});
31+
assert.equal(status, 0, `Command failed (status = ${status})`);
32+
}

0 commit comments

Comments
 (0)