Skip to content

Commit 3518fcc

Browse files
committed
Resolve comments
1 parent dc9f936 commit 3518fcc

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

bin/sql-formatter-cli.cjs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ class SqlFormatterCli {
9999
return this.parseFile(localConfig);
100100
}
101101

102-
async findConfig(dir = __dirname) {
102+
findConfig(dir = __dirname) {
103103
const filePath = path.join(dir, '.sql-formatter.json');
104104
if (!fs.existsSync(filePath)) {
105105
const parentDir = path.resolve(dir, '..');
106106
if (parentDir === dir) {
107107
return null;
108108
}
109-
return await this.findConfig(parentDir);
109+
return this.findConfig(parentDir);
110110
}
111111

112112
return filePath;
@@ -131,12 +131,19 @@ class SqlFormatterCli {
131131
}
132132

133133
async readFile(filename) {
134-
return promisify(fs.readFile)(filename, { encoding: 'utf-8' }).catch(e => {
134+
try {
135+
136+
137+
return promisify(fs.readFile)(filename, { encoding: 'utf-8' })
138+
} catch (e) {
139+
140+
135141
this.exitWhenIOError(e, filename);
136142
console.error('An unknown error has occurred, please file a bug report at:');
137143
console.log('https://github.com/sql-formatter-org/sql-formatter/issues\n');
138144
throw e;
139-
});
145+
146+
}
140147
}
141148

142149
exitWhenIOError(e, infile) {

0 commit comments

Comments
 (0)