diff options
-rw-r--r-- | packages/taler-wallet-cli/rollup.config.js | 15 | ||||
-rw-r--r-- | packages/taler-wallet-cli/src/index.ts | 4 |
2 files changed, 16 insertions, 3 deletions
diff --git a/packages/taler-wallet-cli/rollup.config.js b/packages/taler-wallet-cli/rollup.config.js index 15ec58e5e..372d7537e 100644 --- a/packages/taler-wallet-cli/rollup.config.js +++ b/packages/taler-wallet-cli/rollup.config.js @@ -6,6 +6,10 @@ import builtins from "builtin-modules"; import pkg from "./package.json"; import sourcemaps from "rollup-plugin-sourcemaps"; import path from "path"; +import replace from "@rollup/plugin-replace"; +import child_process from 'child_process'; + +const printedVersion = `${pkg.version}-${getGitRevision()}` export default { input: "lib/index.js", @@ -25,6 +29,10 @@ export default { }, external: builtins, plugins: [ + replace({ + __VERSION__: printedVersion, + }), + nodeResolve({ preferBuiltins: true, exportConditions: ["node"], @@ -40,3 +48,10 @@ export default { json(), ], }; + +function getGitRevision() { + return child_process.execSync(`git rev-parse --abbrev-ref HEAD`, { + encoding: 'utf-8', + windowsHide: true, + }).trim(); +} diff --git a/packages/taler-wallet-cli/src/index.ts b/packages/taler-wallet-cli/src/index.ts index 22a2d8552..3b72f74b7 100644 --- a/packages/taler-wallet-cli/src/index.ts +++ b/packages/taler-wallet-cli/src/index.ts @@ -142,9 +142,7 @@ function applyVerbose(verbose: boolean): void { } function printVersion(): void { - // eslint-disable-next-line @typescript-eslint/no-var-requires - const info = require("../package.json"); - console.log(`${info.version}`); + console.log("__VERSION__"); process.exit(0); } |