@@ -4,46 +4,15 @@ import { exec, execSync } from 'child_process';
4
4
import which from 'which' ;
5
5
6
6
const NodePathTester = {
7
- _timeout : null ,
8
- _bin : null ,
9
7
_knownGoodValues : new Map ( ) ,
10
8
11
- schedule ( bin ) {
12
- // Assume it's valid until we know otherwise.
13
- this . valid = true ;
14
- if ( this . _timeout !== null ) {
15
- clearTimeout ( this . _timeout ) ;
16
- this . _timeout = null ;
17
- }
18
-
19
- // When an Atom window loads, we get the main config first; then any config
20
- // overrides from project-config or atomic-management a couple seconds
21
- // later; then any further overrides from `.linter-eslint` files a couple
22
- // seconds after that.
23
- //
24
- // So we wait a few seconds before we try this version of Node, lest we
25
- // complain about a version that isn't even the correct setting for this
26
- // project.
27
- return new Promise ( ( resolve , reject ) => {
28
- this . _timeout = setTimeout ( ( ) => {
29
- this . test ( bin ) . then ( resolve ) . catch ( reject ) ;
30
- } , 3000 ) ;
31
- } ) ;
32
- } ,
33
-
34
- // Tries to discern the absolute path to the user's `node` binary. TODO:
35
- // Handle relative paths, not just the bare value `node`.
9
+ // Tries to discern the absolute path to the user's `node` binary.
10
+ // TODO: Handle relative paths, not just the bare value `node`.
36
11
resolve ( bin ) {
37
- if ( bin . startsWith ( '/' ) && existsSync ( bin ) ) { return Promise . resolve ( bin ) ; }
38
- return new Promise ( ( resolve , reject ) => {
39
- which ( bin , ( err , resolvedPath ) => {
40
- if ( err ) {
41
- reject ( err ) ;
42
- } else {
43
- resolve ( resolvedPath ) ;
44
- }
45
- } ) ;
46
- } ) ;
12
+ if ( bin . startsWith ( '/' ) && existsSync ( bin ) ) {
13
+ return Promise . resolve ( bin ) ;
14
+ }
15
+ return which ( bin ) ;
47
16
} ,
48
17
49
18
testSync ( bin ) {
@@ -59,20 +28,18 @@ const NodePathTester = {
59
28
} ,
60
29
61
30
test ( bin ) {
62
- console . log ( `actually testing ${ bin } ` ) ;
63
31
if ( this . _knownGoodValues . has ( bin ) ) {
64
- return Promise . resolve (
65
- this . _knownGoodValues . get ( bin )
66
- ) ;
32
+ return Promise . resolve ( this . _knownGoodValues . get ( bin ) ) ;
67
33
}
34
+ // Assume it's valid until we know otherwise.
35
+ this . valid = true ;
68
36
return new Promise ( ( resolve , reject ) => {
69
37
exec ( `${ bin } --version` , ( err , stdout ) => {
70
38
if ( err ) {
71
- console . log ( `nope` ) ;
39
+ console . log ( 'error!' ) ;
72
40
this . valid = false ;
73
41
reject ( err ) ;
74
42
} else {
75
-
76
43
this . _knownGoodValues . set ( bin , stdout ) ;
77
44
resolve ( stdout ) ;
78
45
}
0 commit comments