@@ -125,27 +125,39 @@ class Config {
125125}
126126
127127class Local extends Config {
128- static CONFIG_FILE_PATH = "{{ spec .title | caseLower }}.json";
128+ static CONFIG_FILE_PATH = "{{ spec .title | caseLower }}.config.json";
129+ static CONFIG_FILE_PATH_LEGACY = "{{ spec .title | caseLower }}.json";
129130 configDirectoryPath = ""
130131
131- constructor(path = Local.CONFIG_FILE_PATH) {
132+ constructor(path = Local.CONFIG_FILE_PATH, legacyPath = Local.CONFIG_FILE_PATH_LEGACY) {
133+ let absolutePath = Local.findConfigFile(path) || Local.findConfigFile(legacyPath);
134+
135+ if (!absolutePath) {
136+ absolutePath = `${process.cwd()}/${path}`;
137+ }
138+
139+ super(absolutePath);
140+ this.configDirectoryPath = _path.dirname(absolutePath);
141+ }
142+
143+ static findConfigFile(filename) {
132144 let currentPath = process.cwd();
133- let absolutePath = `${currentPath}/${path}`;
134145
135146 while (true) {
136- if (fs.existsSync( `${currentPath}/${path}`)) {
137- absolutePath = `${currentPath}/${path}`;
138- break
139- } else {
140- const parentDirectory = _path.dirname(currentPath);
141- if (parentDirectory === currentPath) { // we hit the top directory
142- break ;
143- }
144- currentPath = parentDirectory
147+ const filePath = `${currentPath}/${filename}`;
148+
149+ if (fs.existsSync(filePath)) {
150+ return filePath;
151+ }
152+
153+ const parentDirectory = _path.dirname(currentPath) ;
154+ if (parentDirectory === currentPath) {
155+ break;
145156 }
157+ currentPath = parentDirectory;
146158 }
147- super(absolutePath);
148- this.configDirectoryPath =_path.dirname(absolutePath) ;
159+
160+ return null ;
149161 }
150162
151163 getDirname() {
0 commit comments