Skip to content

Commit

Permalink
fix(add-caching): ensure lerna.json is configured automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesHenry committed Sep 30, 2022
1 parent 07271fe commit 9677cda
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/lerna/commands/add-caching/index.js
Expand Up @@ -26,6 +26,21 @@ class AddCachingCommand extends Command {
);
// eslint-disable-next-line no-process-exit
process.exit(1);
} // TODO: remove auto-setting useNx: true in v6
else if (!this.options.useNx) {
const lernaJsonPath = joinPathFragments(workspaceRoot, "lerna.json");
try {
const lernaJson = readJsonFile(lernaJsonPath);
lernaJson.useNx = true;
writeJsonFile(lernaJsonPath, lernaJson);
} catch {
this.logger.error(
"add-caching",
"The `add-caching` command is only available when using the Nx task runner (set `useNx` to `true` in `lerna.json`)"
);
// eslint-disable-next-line no-process-exit
process.exit(1);
}
}

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

0 comments on commit 9677cda

Please sign in to comment.