1
1
import test from 'brittle' ;
2
2
import { getBinPath } from 'get-bin-path'
3
3
import { prepareEnvironment } from '@jakechampion/cli-testing-library' ;
4
+ import { readFileSync } from "node:fs" ;
5
+ import { fileURLToPath } from "node:url" ;
6
+ import { dirname , join } from "node:path" ;
7
+ const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
8
+
9
+ const packageJson = readFileSync ( join ( __dirname , "../../package.json" ) , {
10
+ encoding : "utf-8" ,
11
+ } ) ;
12
+ const version = JSON . parse ( packageJson ) . version ;
4
13
5
14
const cli = await getBinPath ( )
6
15
@@ -12,7 +21,7 @@ test('--version should return version number on stdout and zero exit code', asyn
12
21
const { code, stdout, stderr } = await execute ( process . execPath , `${ cli } --version` ) ;
13
22
14
23
t . is ( code , 0 ) ;
15
- t . alike ( stdout , [ ' js-compute-runtime 0.5.4' ] )
24
+ t . alike ( stdout , [ ` js-compute-runtime ${ version } ` ] )
16
25
t . alike ( stderr , [ ] )
17
26
} ) ;
18
27
@@ -24,6 +33,6 @@ test('-V should return version number on stdout and zero exit code', async funct
24
33
const { code, stdout, stderr } = await execute ( process . execPath , `${ cli } -V` ) ;
25
34
26
35
t . is ( code , 0 ) ;
27
- t . alike ( stdout , [ ' js-compute-runtime 0.5.4' ] )
36
+ t . alike ( stdout , [ ` js-compute-runtime ${ version } ` ] )
28
37
t . alike ( stderr , [ ] )
29
38
} ) ;
0 commit comments