Skip to content

Commit cde2f52

Browse files
committed
Move async code out of constructor
1 parent 959577a commit cde2f52

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

bin/sql-formatter-cli.cjs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ class SqlFormatterCli {
1414
constructor() {
1515
this.parser = this.getParser();
1616
this.args = this.parser.parse_args();
17-
this.cfg = this.readConfig();
17+
}
1818

19-
this.getInput().then(input => {
20-
this.query = input;
21-
const formattedQuery = format(this.query, this.cfg).trim() + '\n';
22-
this.writeOutput(this.getOutputFile(this.args), formattedQuery);
23-
});
19+
async run() {
20+
this.cfg = this.readConfig();
21+
this.query = await this.getInput();
22+
const formattedQuery = format(this.query, this.cfg).trim() + '\n';
23+
this.writeOutput(this.getOutputFile(this.args), formattedQuery);
2424
}
2525

2626
getParser() {
@@ -150,4 +150,5 @@ class SqlFormatterCli {
150150
}
151151
}
152152

153-
new SqlFormatterCli();
153+
const cli = new SqlFormatterCli();
154+
cli.run();

0 commit comments

Comments
 (0)