@@ -34,13 +34,13 @@ export interface SgcConfig {
34
34
}
35
35
36
36
class Config {
37
- altPath : string | null ;
37
+ alternativeCwd : string | null ;
38
38
39
- fileName : string ;
39
+ sgcConfigName : string ;
40
40
41
- constructor ( altPath : string | null = null , fileName = '.sgcrc' ) {
42
- this . altPath = altPath ;
43
- this . fileName = fileName ;
41
+ constructor ( alternativeCwd : string | null = null , sgcConfigName = '.sgcrc' ) {
42
+ this . alternativeCwd = alternativeCwd ;
43
+ this . sgcConfigName = sgcConfigName ;
44
44
45
45
this . setConfig ( ) ;
46
46
}
@@ -60,9 +60,11 @@ class Config {
60
60
61
61
private getConfigPath ( ) : { path : string ; defaultPath : string ; type : 'rc' | 'js' | 'pkg' } {
62
62
// paths
63
- const localPath = Config . getPath ( findup ( this . fileName , { cwd : this . altPath || cwd } ) ) ;
63
+ const localPath = Config . getPath ( (
64
+ findup ( this . sgcConfigName , { cwd : this . alternativeCwd || cwd } )
65
+ ) ) ;
64
66
const localJsPath = Config . getPath ( findup ( 'sgc.config.js' , { cwd } ) ) ;
65
- const globalPath = Config . getPath ( path . join ( homedir , this . fileName ) ) ;
67
+ const globalPath = Config . getPath ( path . join ( homedir , this . sgcConfigName ) ) ;
66
68
const globalJsPath = Config . getPath ( path . join ( homedir , 'sgc.config.js' ) ) ;
67
69
const packageJson = Config . getPath ( findup ( 'package.json' , { cwd } ) ) ;
68
70
const defaultPath = Config . getPath ( path . join ( __dirname , '..' , '.sgcrc' ) ) as string ;
@@ -155,6 +157,10 @@ class Config {
155
157
public get config ( ) : SgcConfig {
156
158
return this . setConfig ( ) ;
157
159
}
160
+
161
+ public get configPath ( ) : string {
162
+ return this . getConfigPath ( ) . path ;
163
+ }
158
164
}
159
165
160
166
export default Config ;
0 commit comments