Skip to content

Commit

Permalink
bin: Use esbuild's define argument to inject the version.
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron committed Jan 13, 2022
1 parent b93d120 commit 8937962
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion script/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ build({
target: "es2020",
bundle: true,
sourcemap: true,
banner: { js: `const version = "${version}";\n` },
define: { WEBAUTHN_JSON_VERSION: JSON.stringify(version) },
outfile: "dist/bin/main.js",
});
4 changes: 2 additions & 2 deletions src/bin/main.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* tslint:disable:no-console no-var-requires */

declare const version: string;
declare const WEBAUTHN_JSON_VERSION: string;
import { schema } from "../webauthn-json";

const help = `Usage: ${process.argv[1]} schema`;

const command = process.argv[2];
if (command === "schema") {
const schemaWithVersion = { ...schema, version };
const schemaWithVersion = { ...schema, version: WEBAUTHN_JSON_VERSION };
console.log(JSON.stringify(schemaWithVersion, null, " "));
} else {
console.log(help);
Expand Down

0 comments on commit 8937962

Please sign in to comment.