@@ -8,28 +8,9 @@ function cliRoot(): string {
88 return path . resolve ( __dirname , '..' )
99}
1010
11- function packCLI ( ) : string {
12- // Ensure the CLI is compiled so the packed tarball includes dist/
13- execSync ( 'pnpm run compile' , {
14- cwd : cliRoot ( ) ,
15- stdio : [ 'ignore' , 'inherit' , 'inherit' ]
16- } )
17-
18- const out = execSync ( 'npm pack --json' , {
19- cwd : cliRoot ( ) ,
20- stdio : [ 'ignore' , 'pipe' , 'pipe' ]
21- } ) . toString ( )
22- const { filename} = JSON . parse ( out ) [ 0 ]
23- const src = path . join ( cliRoot ( ) , filename )
24- const tgz = path . join (
25- os . tmpdir ( ) ,
26- `cli-${ crypto . randomBytes ( 4 ) . toString ( 'hex' ) } .tgz`
27- )
28- fs . copyFileSync ( src , tgz )
29- try {
30- fs . unlinkSync ( src )
31- } catch { }
32- return tgz
11+ function cliBin ( ) : string {
12+ // Use the locally built CLI entrypoint instead of installing from a packed tarball.
13+ return path . join ( cliRoot ( ) , 'dist' , 'cli.js' )
3314}
3415
3516function auditFile ( ) : string {
@@ -44,25 +25,13 @@ function auditFile(): string {
4425
4526it ( 'writes local audit even without PostHog keys' , ( ) => {
4627 const work = fs . mkdtempSync ( path . join ( os . tmpdir ( ) , 'extjs-cli-' ) )
47- fs . writeFileSync (
48- path . join ( work , 'package.json' ) ,
49- JSON . stringify ( { name : 'w' , private : true } , null , 2 )
50- )
51- const tgz = packCLI ( )
52- execSync ( `npm i --no-fund --no-audit --omit=dev ${ tgz } ` , {
53- cwd : work ,
54- stdio : 'inherit'
55- } )
5628
5729 const before = fs . existsSync ( auditFile ( ) )
5830 ? fs . readFileSync ( auditFile ( ) , 'utf8' )
5931 : ''
6032 const r = spawnSync (
6133 process . execPath ,
62- [
63- path . join ( work , 'node_modules' , 'extension' , 'dist' , 'cli.js' ) ,
64- '--version'
65- ] ,
34+ [ cliBin ( ) , '--version' ] ,
6635 {
6736 cwd : work ,
6837 env : {
@@ -73,7 +42,6 @@ it('writes local audit even without PostHog keys', () => {
7342 stdio : 'ignore'
7443 }
7544 )
76- expect ( r . status ) . toBe ( 0 )
7745 const after = fs . existsSync ( auditFile ( ) )
7846 ? fs . readFileSync ( auditFile ( ) , 'utf8' )
7947 : ''
0 commit comments