@@ -34,20 +34,26 @@ function getConfigPath(configPath) {
3434 var HOME = process . env . HOME || process . env . HOMEPATH || process . env . USERPROFILE ;
3535 // Since `process.cwd()` can be absolutely anything, build default path
3636 // relative to current directory:
37- var defaultConfigPath = __dirname + '/ ../config/csscomb.json';
37+ var defaultConfigPath = path . join ( __dirname , ' ../config/csscomb.json') ;
3838
39- configPath = configPath || process . cwd ( ) + '/ .csscomb.json';
39+ configPath = configPath || path . join ( process . cwd ( ) , ' .csscomb.json') ;
4040
4141 // If we've finally found a config, return its path:
4242 if ( fs . existsSync ( configPath ) ) return configPath ;
4343
4444 // If we are in HOME dir already and yet no config file, return a default
45- // one from our package:
46- if ( path . dirname ( configPath ) === HOME ) return defaultConfigPath ;
45+ // one from our package.
46+ // If project is located not under HOME, compare to root instead.
47+ // Since there appears to be no good way to get root path in
48+ // Windows, assume that if current dir has no parent dir, we're in
49+ // root.
50+ var dirname = path . dirname ( configPath ) ;
51+ var parentDirname = path . dirname ( dirname ) ;
52+ if ( dirname === HOME || dirname === parentDirname ) return defaultConfigPath ;
4753
4854 // If there is no config in this directory, go one level up and look for
4955 // a config there:
50- configPath = path . dirname ( path . dirname ( configPath ) ) + '/ .csscomb.json';
56+ configPath = path . join ( parentDirname , ' .csscomb.json') ;
5157 return getConfigPath ( configPath ) ;
5258}
5359
0 commit comments