@@ -125,27 +125,39 @@ class Config {
125
125
}
126
126
127
127
class 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";
129
130
configDirectoryPath = ""
130
131
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) {
132
144
let currentPath = process.cwd();
133
- let absolutePath = `${currentPath}/${path}`;
134
145
135
146
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;
145
156
}
157
+ currentPath = parentDirectory;
146
158
}
147
- super(absolutePath);
148
- this.configDirectoryPath =_path.dirname(absolutePath) ;
159
+
160
+ return null ;
149
161
}
150
162
151
163
getDirname() {
0 commit comments