@@ -65,10 +65,14 @@ async function main(argv = process.argv) {
65
65
hadFailure = true ;
66
66
}
67
67
68
+ const shellcheckDefaultSearchRoots = [ './src' , './scripts' , './tests' ] ;
69
+ const searchRoots = shellcheckDefaultSearchRoots
70
+ . map ( ( p ) => path . resolve ( process . cwd ( ) , p ) )
71
+ . filter ( ( p ) => fs . existsSync ( p ) ) ;
72
+
68
73
// Linting shell scripts (this does not have auto-fixing)
69
74
const shellCheckArgs = [
70
- './src' ,
71
- './scripts' ,
75
+ ...searchRoots ,
72
76
'-type' ,
73
77
'f' ,
74
78
'-regextype' ,
@@ -82,18 +86,24 @@ async function main(argv = process.argv) {
82
86
] ;
83
87
if ( utils . commandExists ( 'find' ) && utils . commandExists ( 'shellcheck' ) ) {
84
88
console . error ( 'Running shellcheck:' ) ;
85
- console . error ( ' ' + [ 'find' , ...shellCheckArgs ] . join ( ' ' ) ) ;
86
- try {
87
- childProcess . execFileSync ( 'find' , shellCheckArgs , {
88
- stdio : [ 'inherit' , 'inherit' , 'inherit' ] ,
89
- windowsHide : true ,
90
- encoding : 'utf-8' ,
91
- shell : platform === 'win32' ? true : false ,
92
- cwd : process . cwd ( ) ,
93
- } ) ;
94
- } catch ( err ) {
95
- console . error ( 'Shellcheck failed.' + err ) ;
96
- hadFailure = true ;
89
+ if ( searchRoots . length === 0 ) {
90
+ console . warn (
91
+ 'No search roots found for shellcheck. Skipping shellcheck.' ,
92
+ ) ;
93
+ } else {
94
+ console . error ( ' ' + [ 'find' , ...shellCheckArgs ] . join ( ' ' ) ) ;
95
+ try {
96
+ childProcess . execFileSync ( 'find' , shellCheckArgs , {
97
+ stdio : [ 'inherit' , 'inherit' , 'inherit' ] ,
98
+ windowsHide : true ,
99
+ encoding : 'utf-8' ,
100
+ shell : platform === 'win32' ? true : false ,
101
+ cwd : process . cwd ( ) ,
102
+ } ) ;
103
+ } catch ( err ) {
104
+ console . error ( 'Shellcheck failed. ' + err ) ;
105
+ hadFailure = true ;
106
+ }
97
107
}
98
108
} else {
99
109
console . warn (
0 commit comments