11import path from 'path' ;
22
33import { findup , getContent } from '../configLoader' ;
4+ import { isInTest } from '../common/util.js' ;
45
56export default loader ;
67
78/**
89 * Command line config helpers
9- * Shamelessly ripped from with slight modifications:
10+ * Shamelessly ripped from with slight modifications:
1011 * https://github.com/jscs-dev/node-jscs/blob/master/lib/cli-config.js
1112 */
1213
@@ -27,7 +28,7 @@ function loader(configs, config, cwd) {
2728
2829 content = getContent (
2930 findup ( configs , { nocase : true , cwd : directory } , function ( configPath ) {
30- if ( path . basename ( configPath ) === 'package.json' ) {
31+ if ( path . basename ( configPath ) === 'package.json' ) {
3132 // return !!this.getContent(configPath);
3233 }
3334
@@ -38,20 +39,22 @@ function loader(configs, config, cwd) {
3839 if ( content ) {
3940 return content ;
4041 }
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+ }
5659 }
57- }
60+ }
0 commit comments