|
6 | 6 | * to the requested command, and guarantees the socket is closed afterwards. |
7 | 7 | */ |
8 | 8 |
|
| 9 | +import { createRequire } from 'node:module'; |
9 | 10 | import * as path from 'node:path'; |
10 | 11 | import { Command } from 'commander'; |
11 | 12 |
|
@@ -33,6 +34,15 @@ import { remove } from './commands/remove'; |
33 | 34 | import { login, logout } from './commands/login'; |
34 | 35 | import { setupTypes } from './commands/types'; |
35 | 36 |
|
| 37 | +/** |
| 38 | + * Read at runtime rather than hardcoded. The literal that used to live here said |
| 39 | + * 0.1.0 while the published package was 1.0.0 — release-please bumps package.json |
| 40 | + * and had no way to reach a string in the source, so `--version` lied to every |
| 41 | + * user. dist/cli.js sits one level below package.json in both the repository and |
| 42 | + * the installed package, so the relative path holds in both. |
| 43 | + */ |
| 44 | +const { version } = createRequire(__filename)('../package.json') as { version: string }; |
| 45 | + |
36 | 46 | const program = new Command(); |
37 | 47 |
|
38 | 48 | let verbose = false; |
@@ -171,7 +181,7 @@ function action(fn: () => Promise<void>): () => Promise<void> { |
171 | 181 | program |
172 | 182 | .name('iob-sync') |
173 | 183 | .description('Sync ioBroker scripts with a local folder') |
174 | | - .version('0.1.0') |
| 184 | + .version(version) |
175 | 185 | .option('-n, --dry-run', 'show what would happen without changing anything') |
176 | 186 | .option('-v, --verbose', 'verbose output') |
177 | 187 | .option('-C, --cwd <dir>', 'run as if started in <dir>') |
|
0 commit comments