@@ -15,17 +15,25 @@ const { shortSha } = require('./utils');
15
15
16
16
const isWindows = process . platform === 'win32' ;
17
17
18
+ const LINT_RESULTS = {
19
+ SKIPPED : 'skipped' ,
20
+ FAILED : 'failed' ,
21
+ SUCCESS : 'success'
22
+ } ;
23
+
18
24
class LandingSession extends Session {
19
- constructor ( cli , req , dir , prid , backport , autorebase ) {
25
+ constructor ( cli , req , dir , prid , backport , lint , autorebase ) {
20
26
super ( cli , dir , prid ) ;
21
27
this . req = req ;
22
28
this . backport = backport ;
29
+ this . lint = lint ;
23
30
this . autorebase = autorebase ;
24
31
}
25
32
26
33
get argv ( ) {
27
34
const args = super . argv ;
28
35
args . backport = this . backport ;
36
+ args . lint = this . lint ;
29
37
args . autorebase = this . autorebase ;
30
38
return args ;
31
39
}
@@ -147,14 +155,18 @@ class LandingSession extends Session {
147
155
async validateLint ( ) {
148
156
// The linter is currently only run on non-Windows platforms.
149
157
if ( os . platform ( ) === 'win32' ) {
150
- return true ;
158
+ return LINT_RESULTS . SKIPPED ;
159
+ }
160
+
161
+ if ( ! this . lint ) {
162
+ return LINT_RESULTS . SKIPPED ;
151
163
}
152
164
153
165
try {
154
166
await runAsync ( 'make' , [ 'lint' ] ) ;
155
- return true ;
167
+ return LINT_RESULTS . SUCCESS ;
156
168
} catch {
157
- return false ;
169
+ return LINT_RESULTS . FAILED ;
158
170
}
159
171
}
160
172
@@ -229,13 +241,13 @@ class LandingSession extends Session {
229
241
const patch = await this . downloadAndPatch ( ) ;
230
242
231
243
const cleanLint = await this . validateLint ( ) ;
232
- if ( ! cleanLint ) {
244
+ if ( cleanLint === LINT_RESULTS . FAILED ) {
233
245
const tryFixLint = await cli . prompt (
234
246
'Lint failed - try fixing with \'make lint-js-fix\'?' ) ;
235
247
if ( tryFixLint ) {
236
248
await runAsync ( 'make' , [ 'lint-js-fix' ] ) ;
237
249
const fixed = await this . validateLint ( ) ;
238
- if ( ! fixed ) {
250
+ if ( fixed === LINT_RESULTS . FAILED ) {
239
251
cli . warn ( 'Patch still contains lint errors. ' +
240
252
'Please fix manually before proceeding' ) ;
241
253
}
@@ -253,7 +265,7 @@ class LandingSession extends Session {
253
265
'`git node land --continue`.' ) ;
254
266
process . exit ( 1 ) ;
255
267
}
256
- } else {
268
+ } else if ( cleanLint === LINT_RESULTS . SUCCESS ) {
257
269
cli . ok ( 'Lint passed cleanly' ) ;
258
270
}
259
271
0 commit comments