Skip to content

Commit 6fa946f

Browse files
committed
[changed] put back "defaultDryRun" option
#19 (comment) It seems there had been some confusion on my side :)
1 parent e049233 commit 6fa946f

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,18 @@ You can set a custom message for github release via `--notes` CLI option:
170170
> release patch --notes "This is a small fix"
171171
```
172172

173+
#### If you need `dry-run` mode by default
174+
175+
You can setup the `release-script` to run in `dry-run` mode by default.
176+
177+
It can be done by setting `"true"` the `defaultDryRun` option in your `package.json`:
178+
```json
179+
"release-script": {
180+
"defaultDryRun": "true"
181+
}
182+
```
183+
Then to actually run your commands you will have to add `--run`.
184+
173185

174186
#### This script does the following steps:
175187

src/release.js

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ const yargsConf = yargs
8383
alias: 'n',
8484
describe: 'This option toggles "dry run" mode'
8585
})
86+
.option('run', {
87+
describe: 'You need this when "defaultDryRun": "true"'
88+
})
8689
.option('verbose', {
8790
describe: 'Increased debug output'
8891
})
@@ -115,8 +118,26 @@ if (!argv.skipVersionBumping && versionBumpOptions.type === undefined && version
115118

116119
let notesForRelease = argv.notes;
117120

118-
const dryRunMode = argv.dryRun;
119-
if (dryRunMode) console.log('DRY RUN'.magenta);
121+
const isDefaultDryRunOptionSetTrue =
122+
configOptions.defaultDryRun === true ||
123+
configOptions.defaultDryRun === 'true';
124+
125+
let dryRunMode;
126+
if (argv.run) {
127+
dryRunMode = false;
128+
} else {
129+
dryRunMode = argv.dryRun || isDefaultDryRunOptionSetTrue;
130+
}
131+
132+
if (dryRunMode) {
133+
console.log('DRY RUN'.magenta);
134+
135+
if (isDefaultDryRunOptionSetTrue) {
136+
console.log('------------------------------------------------------');
137+
console.log('To actually run your command please add "--run" option'.yellow);
138+
console.log('------------------------------------------------------');
139+
}
140+
}
120141

121142
if (argv.preid) console.log('"--preid" detected. Documents will not be published'.yellow);
122143
if (argv.onlyDocs && !argv.preid) console.log('Publish only documents'.yellow);

0 commit comments

Comments
 (0)