8000 fix(add-caching): ensure lerna.json is configured automatically · lerna/lerna@9677cda · GitHub
[go: up one dir, main page]

Skip to content

Commit 9677cda

Browse files
committed
fix(add-caching): ensure lerna.json is configured automatically
1 parent 07271fe commit 9677cda

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

core/lerna/commands/add-caching/index.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ class AddCachingCommand extends Command {
2626
);
2727
// eslint-disable-next-line no-process-exit
2828
process.exit(1);
29+
} // TODO: remove auto-setting useNx: true in v6
30+
else if (!this.options.useNx) {
31+
const lernaJsonPath = joinPathFragments(workspaceRoot, "lerna.json");
32+
try {
33+
const lernaJson = readJsonFile(lernaJsonPath);
34+
lernaJson.useNx = true;
35+
writeJsonFile(lernaJsonPath, lernaJson);
36+
} catch {
37+
this.logger.error(
38+
"add-caching",
39+
"The `add-caching` command is only available when using the Nx task runner (set `useNx` to `true` in `lerna.json`)"
40+
);
41+
// eslint-disable-next-line no-process-exit
42+
process.exit(1);
43+
}
2944
}
3045

3146
const packages = this.packageGraph?.rawPackageList || [];

0 commit comments

Comments
 (0)
0