Skip to content

Commit d5ada35

Browse files
Merge pull request #1116 from appwrite/feat-appwrite-config-json
fix: update localConfig from appwrite.json to appwrite.config.json
2 parents 0a16a34 + 1bf9b04 commit d5ada35

File tree

1 file changed

+26
-14
lines changed

1 file changed

+26
-14
lines changed

templates/cli/lib/config.js.twig

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,27 +125,39 @@ class Config {
125125
}
126126

127127
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";
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

Comments
 (0)