File tree 2 files changed +14
-9
lines changed
2 files changed +14
-9
lines changed Original file line number Diff line number Diff line change 1
1
2
2
// Command to lint src code
3
3
4
- const path = require ( 'path' ) ;
5
4
const CLIEngine = require ( 'eslint' ) . CLIEngine ;
6
- const shell = require ( 'shelljs' ) ;
7
5
const logger = require ( './../logger' ) ;
8
6
const glob = require ( 'glob' ) ;
9
7
const { userRootPath } = require ( '../../utils/paths' ) ( ) ;
@@ -22,14 +20,16 @@ module.exports = () => {
22
20
const cli = new CLIEngine ( eslintCLI ) ;
23
21
const report = cli . executeOnFiles ( files ) ;
24
22
const formatter = cli . getFormatter ( ) ;
25
- logger . log ( formatter ( report . results ) ) ;
23
+ logger . log ( `${ formatter ( report . results ) } \n` ) ;
24
+ process . exit ( report . errorCount + report . warningCount > 0 ? 1 : 0 ) ;
26
25
} ;
27
26
28
27
// Check to see if eslint file exists
29
28
const eslintrc = glob . sync ( `${ userRootPath } /.*eslintrc*` ) ;
30
29
if ( ! eslintrc . length ) {
31
30
logger . error ( 'You do not have an eslintrc file in the root of your project' ) ;
32
- process . exit ( ) ;
31
+ process . exit ( 1 ) ;
33
32
}
33
+
34
34
lint ( ) ;
35
35
} ;
Original file line number Diff line number Diff line change @@ -5,11 +5,15 @@ const glob = require('glob');
5
5
const { userRootPath } = require ( '../../utils/paths' ) ( ) ;
6
6
7
7
module . exports = ( ) => {
8
+ const handleError = ( error ) => {
9
+ logger . error ( error ) ;
10
+ process . exit ( 1 ) ;
11
+ } ;
12
+
8
13
// Check to see if stylelint file exists
9
14
const stylelintrc = glob . sync ( `${ userRootPath } /.stylelintrc` ) ;
10
15
if ( ! stylelintrc . length ) {
11
- logger . error ( 'You do not have a .stylelintrc file in the root of your project' ) ;
12
- process . exit ( ) ;
16
+ handleError ( 'You do not have a .stylelintrc file in the root of your project' ) ;
13
17
}
14
18
15
19
stylelint . lint ( {
@@ -18,13 +22,14 @@ module.exports = () => {
18
22
} )
19
23
. then ( ( result ) => {
20
24
if ( result . output ) {
21
- logger . log ( result . output ) ;
25
+ handleError ( `\n ${ result . output } ` ) ;
22
26
} else {
23
27
logger . log ( '' ) ;
24
28
logger . end ( 'Your styles look good! ✨\n' ) ;
29
+ process . exit ( 0 ) ;
25
30
}
26
31
} )
27
- . catch ( ( err ) => {
28
- logger . error ( err . stack ) ;
32
+ . catch ( ( error ) => {
33
+ handleError ( error . stack ) ;
29
34
} ) ;
30
35
} ;
You can’t perform that action at this time.
0 commit comments