1
1
import path from 'path' ;
2
2
3
3
import { findup , getContent } from '../configLoader' ;
4
+ import { isInTest } from '../common/util.js' ;
4
5
5
6
export default loader ;
6
7
7
8
/**
8
9
* Command line config helpers
9
- * Shamelessly ripped from with slight modifications:
10
+ * Shamelessly ripped from with slight modifications:
10
11
* https://github.com/jscs-dev/node-jscs/blob/master/lib/cli-config.js
11
12
*/
12
13
@@ -27,7 +28,7 @@ function loader(configs, config, cwd) {
27
28
28
29
content = getContent (
29
30
findup ( configs , { nocase : true , cwd : directory } , function ( configPath ) {
30
- if ( path . basename ( configPath ) === 'package.json' ) {
31
+ if ( path . basename ( configPath ) === 'package.json' ) {
31
32
// return !!this.getContent(configPath);
32
33
}
33
34
@@ -38,20 +39,22 @@ function loader(configs, config, cwd) {
38
39
if ( content ) {
39
40
return content ;
40
41
}
41
-
42
- // Try to load standard configs from home dir
43
- var directoryArr = [ process . env . USERPROFILE , process . env . HOMEPATH , process . env . HOME ] ;
44
- for ( var i = 0 , dirLen = directoryArr . length ; i < dirLen ; i ++ ) {
45
- if ( ! directoryArr [ i ] ) {
46
- continue ;
47
- }
48
-
49
- for ( var j = 0 , len = configs . length ; j < len ; j ++ ) {
50
- content = getContent ( configs [ j ] , directoryArr [ i ] ) ;
51
-
52
- if ( content ) {
53
- return content ;
54
- }
55
- }
42
+ /* istanbul ignore if */
43
+ if ( ! isInTest ( ) ) {
44
+ // Try to load standard configs from home dir
45
+ var directoryArr = [ process . env . USERPROFILE , process . env . HOMEPATH , process . env . HOME ] ;
46
+ for ( var i = 0 , dirLen = directoryArr . length ; i < dirLen ; i ++ ) {
47
+ if ( ! directoryArr [ i ] ) {
48
+ continue ;
49
+ }
50
+
51
+ for ( var j = 0 , len = configs . length ; j < len ; j ++ ) {
52
+ content = getContent ( configs [ j ] , directoryArr [ i ] ) ;
53
+
54
+ if ( content ) {
55
+ return content ;
56
+ }
57
+ }
58
+ }
56
59
}
57
- }
60
+ }
0 commit comments