Skip to content

Commit 0a94042

Browse files
committed
Use readFile() method also when reading config file
1 parent cde2f52 commit 0a94042

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

bin/sql-formatter-cli.cjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class SqlFormatterCli {
1717
}
1818

1919
async run() {
20-
this.cfg = this.readConfig();
20+
this.cfg = await this.readConfig();
2121
this.query = await this.getInput();
2222
const formattedQuery = format(this.query, this.cfg).trim() + '\n';
2323
this.writeOutput(this.getOutputFile(this.args), formattedQuery);
@@ -63,7 +63,7 @@ class SqlFormatterCli {
6363
return parser;
6464
}
6565

66-
readConfig() {
66+
async readConfig() {
6767
if (
6868
tty.isatty(0) &&
6969
Object.entries(this.args).every(([k, v]) => k === 'language' || v === undefined)
@@ -74,7 +74,7 @@ class SqlFormatterCli {
7474

7575
if (this.args.config) {
7676
try {
77-
const configFile = fs.readFileSync(this.args.config);
77+
const configFile = await this.readFile(this.args.config);
7878
const configJson = JSON.parse(configFile);
7979
return { language: this.args.language, ...configJson };
8080
} catch (e) {

0 commit comments

Comments
 (0)