Skip to content

Commit f6ec09f

Browse files
authored
Merge pull request #416 from atlassian-forks/addAFailOnErrorFlag
2 parents 57a9d9c + 64bb8e7 commit f6ec09f

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ All options are also passed to the transformer, which means you can supply custo
6666
-v, --verbose=0|1|2 show more information about the transform process
6767
(default: 0)
6868
--version print version and exit
69+
--fail-on-error return a 1 exit code when errors were found during execution of codemods
6970
```
7071

7172
This passes the source of all passed through the transform module specified

bin/jscodeshift.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ const parser = require('../src/argsParser')
9595
metavar: 'FILE',
9696
process: file => JSON.parse(fs.readFileSync(file)),
9797
},
98+
failOnError: {
99+
flag: true,
100+
help: 'Return a non-zero code when there are errors',
101+
full: 'fail-on-error',
102+
default: false,
103+
},
98104
version: {
99105
help: 'print version and exit',
100106
callback: function() {

src/Runner.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,10 @@ function run(transformFile, paths, options) {
298298
process.stdout.write(
299299
'Time elapsed: ' + timeElapsed + 'seconds \n'
300300
);
301+
302+
if (options.failOnError && fileCounters.error > 0) {
303+
process.exit(1);
304+
}
301305
}
302306
if (usedRemoteScript) {
303307
temp.cleanupSync();

0 commit comments

Comments
 (0)