Skip to content

Commit

Permalink
Implement --version (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
anuraaga committed Jan 10, 2024
1 parent 007dbc5 commit 31d6ba4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions buildtools/wasm/sql-formatter-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import {
supportedDialects,
} from "sql-formatter";

import { version } from "./package.json";

interface Args {
fix?: boolean;
language: string;
file?: string;
output?: string;
config?: string;
version?: boolean;
}

class SqlFormatterCli {
Expand Down Expand Up @@ -98,8 +99,8 @@ class SqlFormatterCli {
continue;
}
if (arg === "--version") {
args.version = true;
continue;
console.log(version);
exit(0);
}
args.file = arg;
}
Expand Down Expand Up @@ -140,7 +141,11 @@ class SqlFormatterCli {
// a non-interactive execution will differ when no flags are provided, upstream would normally
// default to reading and writing to stdin/stdout. Such usage should be rare in practice
// and it is more important to display the help text when no args are passed.
if (Object.entries(this.args).every(([k, v]) => k === 'language' || v === undefined)) {
if (
Object.entries(this.args).every(
([k, v]) => k === "language" || v === undefined,
)
) {
this.printHelp();
exit(0);
}
Expand Down
1 change: 1 addition & 0 deletions buildtools/wasm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"moduleResolution": "node16",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"strict": true,
"noImplicitAny": true,
"alwaysStrict": true,
Expand Down
Binary file modified internal/wasm/sql-formatter-cli.wasm
Binary file not shown.

0 comments on commit 31d6ba4

Please sign in to comment.