Skip to content

Commit

Permalink
feat(version): specify npmClientArgs with version command
Browse files Browse the repository at this point in the history
  • Loading branch information
fahslaj committed Nov 18, 2022
1 parent 5ddea2b commit 6d71848
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions commands/version/command.js
Expand Up @@ -164,6 +164,10 @@ exports.builder = (yargs, composed) => {
requiresArg: true,
defaultDescription: "v",
},
"npm-client-args": {
describe: "Additional arguments to pass to the npm client when performing 'npm install'.",
type: "array",
},
y: {
describe: "Skip all confirmation prompts.",
alias: "yes",
Expand Down
10 changes: 8 additions & 2 deletions commands/version/index.js
Expand Up @@ -614,11 +614,13 @@ class VersionCommand extends Command {
);
}

const npmClientArgs = this.options.npmClientArgs || [];

if (this.options.npmClient === "pnpm") {
chain = chain.then(() => {
this.logger.verbose("version", "Updating root pnpm-lock.yaml");
return childProcess
.exec("pnpm", ["install", "--lockfile-only", "--ignore-scripts"], this.execOpts)
.exec("pnpm", ["install", "--lockfile-only", "--ignore-scripts", ...npmClientArgs], this.execOpts)
.then(() => {
const lockfilePath = path.join(this.project.rootPath, "pnpm-lock.yaml");
changedFiles.add(lockfilePath);
Expand All @@ -632,7 +634,11 @@ class VersionCommand extends Command {
chain = chain.then(() => {
this.logger.verbose("version", "Updating root package-lock.json");
return childProcess
.exec("npm", ["install", "--package-lock-only", "--ignore-scripts"], this.execOpts)
.exec(
"npm",
["install", "--package-lock-only", "--ignore-scripts", ...npmClientArgs],
this.execOpts
)
.then(() => {
changedFiles.add(lockfilePath);
});
Expand Down
10 changes: 10 additions & 0 deletions core/lerna/schemas/lerna-schema.json
Expand Up @@ -1120,6 +1120,9 @@
"npmClient": {
"$ref": "#/$defs/globals/npmClient"
},
"npmClientArgs": {
"$ref": "#/$defs/globals/npmClientArgs"
},
"loglevel": {
"$ref": "#/$defs/globals/loglevel"
},
Expand Down Expand Up @@ -1420,6 +1423,13 @@
"default": "npm",
"enum": ["npm", "yarn", "pnpm"]
},
"npmClientArgs": {
"type": "array",
"items": {
"type": "string"
},
"description": "Arguments to pass to the npm client when running commands."
},
"loglevel": {
"type": "string",
"description": "The level of logging to use when running commands. Defaults to info if unspecified.",
Expand Down

0 comments on commit 6d71848

Please sign in to comment.