diff --git a/README.md b/README.md index 4de5219..89556d1 100644 --- a/README.md +++ b/README.md @@ -170,6 +170,18 @@ You can set a custom message for github release via `--notes` CLI option: > release patch --notes "This is a small fix" ``` +#### If you need `dry-run` mode by default + +You can setup the `release-script` to run in `dry-run` mode by default. + +It can be done by setting `"true"` the `defaultDryRun` option in your `package.json`: +```json +"release-script": { + "defaultDryRun": "true" +} +``` +Then to actually run your commands you will have to add `--run`. + #### This script does the following steps: diff --git a/src/release.js b/src/release.js index 75513c8..ca510a1 100644 --- a/src/release.js +++ b/src/release.js @@ -83,6 +83,9 @@ const yargsConf = yargs alias: 'n', describe: 'This option toggles "dry run" mode' }) + .option('run', { + describe: 'You need this when "defaultDryRun": "true"' + }) .option('verbose', { describe: 'Increased debug output' }) @@ -115,8 +118,26 @@ if (!argv.skipVersionBumping && versionBumpOptions.type === undefined && version let notesForRelease = argv.notes; -const dryRunMode = argv.dryRun; -if (dryRunMode) console.log('DRY RUN'.magenta); +const isDefaultDryRunOptionSetTrue = + configOptions.defaultDryRun === true || + configOptions.defaultDryRun === 'true'; + +let dryRunMode; +if (argv.run) { + dryRunMode = false; +} else { + dryRunMode = argv.dryRun || isDefaultDryRunOptionSetTrue; +} + +if (dryRunMode) { + console.log('DRY RUN'.magenta); + + if (isDefaultDryRunOptionSetTrue) { + console.log('------------------------------------------------------'); + console.log('To actually run your command please add "--run" option'.yellow); + console.log('------------------------------------------------------'); + } +} if (argv.preid) console.log('"--preid" detected. Documents will not be published'.yellow); if (argv.onlyDocs && !argv.preid) console.log('Publish only documents'.yellow);