diff --git a/README.md b/README.md index 1188eaa6..46f7ee98 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ Use either `NPM_TOKEN` for token authentication or `NPM_USERNAME`, `NPM_PASSWORD | `npmPublish` | Whether to publish the `npm` package to the registry. If `false` the `package.json` version will still be updated. | `false` if the `package.json` [private](https://docs.npmjs.com/files/package.json#private) property is `true`, `true` otherwise. | | `pkgRoot` | Directory path to publish. | `.` | | `tarballDir` | Directory path in which to write the package tarball. If `false` the tarball is not be kept on the file system. | `false` | +| `publishArgs` | Additional arguments for executing the `npm publish` command. For example, to specify a workspace `['--workspace', 'packages']` | `[]` | +| `versionArgs` | Additional arguments for executing the `npm version` command. For example, to specify a workspace `['--workspace', 'packages']` | `[]` | **Note**: The `pkgRoot` directory must contain a `package.json`. The version will be updated only in the `package.json` and `npm-shrinkwrap.json` within the `pkgRoot` directory. diff --git a/lib/prepare.js b/lib/prepare.js index d232eb21..416bbf61 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -2,14 +2,20 @@ const path = require('path'); const {move} = require('fs-extra'); const execa = require('execa'); -module.exports = async (npmrc, {tarballDir, pkgRoot}, {cwd, env, stdout, stderr, nextRelease: {version}, logger}) => { +module.exports = async ( + npmrc, + {tarballDir, pkgRoot, versionArgs}, + {cwd, env, stdout, stderr, nextRelease: {version}, logger} +) => { const basePath = pkgRoot ? path.resolve(cwd, pkgRoot) : cwd; logger.log('Write version %s to package.json in %s', version, basePath); const versionResult = execa( 'npm', - ['version', version, '--userconfig', npmrc, '--no-git-tag-version', '--allow-same-version'], + ['version', version, '--userconfig', npmrc, '--no-git-tag-version', '--allow-same-version'].concat( + versionArgs || [] + ), { cwd: basePath, env, diff --git a/lib/publish.js b/lib/publish.js index ff3af007..44d03571 100644 --- a/lib/publish.js +++ b/lib/publish.js @@ -4,7 +4,7 @@ const getRegistry = require('./get-registry'); const getChannel = require('./get-channel'); const getReleaseInfo = require('./get-release-info'); -module.exports = async (npmrc, {npmPublish, pkgRoot}, pkg, context) => { +module.exports = async (npmrc, {npmPublish, pkgRoot, publishArgs}, pkg, context) => { const { cwd, env, @@ -22,7 +22,7 @@ module.exports = async (npmrc, {npmPublish, pkgRoot}, pkg, context) => { logger.log(`Publishing version ${version} to npm registry on dist-tag ${distTag}`); const result = execa( 'npm', - ['publish', basePath, '--userconfig', npmrc, '--tag', distTag, '--registry', registry], + ['publish', basePath, '--userconfig', npmrc, '--tag', distTag, '--registry', registry].concat(publishArgs || []), {cwd, env, preferLocal: true} ); result.stdout.pipe(stdout, {end: false});