@@ -22,15 +22,26 @@ describe('RunCommand Integration', () => {
2222
2323 // Setup minimal env
2424 await fs . ensureDir ( path . join ( projectDir , 'src' , 'core' ) ) ;
25-
26- // Setup a module with a script
25+ await fs . outputFile ( path . join ( projectDir , 'src' , 'core' , 'package.json' ) , JSON . stringify ( {
26+ name : 'astrical-core' ,
27+ scripts : {
28+ 'test-script' : 'echo test'
29+ }
30+ } ) ) ;
2731 await fs . ensureDir ( path . join ( projectDir , 'src' , 'modules' , 'my-auth' ) ) ;
2832 await fs . outputFile ( path . join ( projectDir , 'src' , 'modules' , 'my-auth' , 'package.json' ) , JSON . stringify ( {
2933 scripts : {
3034 'seed' : 'node seed.js'
3135 }
3236 } ) ) ;
3337
38+ await fs . ensureDir ( path . join ( projectDir , '_site' ) ) ;
39+ await fs . outputFile ( path . join ( projectDir , '_site' , 'package.json' ) , JSON . stringify ( {
40+ scripts : {
41+ 'test-script' : 'echo test'
42+ }
43+ } ) ) ;
44+
3445 spawnMock = vi . mocked ( spawn ) . mockImplementation ( ( ) => {
3546 const child : any = new EventEmitter ( ) ;
3647 child . stdout = new EventEmitter ( ) ;
@@ -55,7 +66,7 @@ describe('RunCommand Integration', () => {
5566 const command = new RunCommand ( cli ) ;
5667 Object . assign ( command , { projectRoot : projectDir } ) ;
5768
58- await command . run ( 'test-script' , '--flag' , { } ) ; // Add options object
69+ await command . run ( { script : 'test-script' , args : [ '--flag' ] } ) ;
5970
6071 expect ( spawnMock ) . toHaveBeenCalledWith (
6172 'npm' ,
@@ -71,18 +82,15 @@ describe('RunCommand Integration', () => {
7182 const command = new RunCommand ( cli ) ;
7283 Object . assign ( command , { projectRoot : projectDir } ) ;
7384
74- await command . run ( 'my-auth:seed' , '--force' , { } ) ; // Add options object
75-
76- // Module scripts run using sh -c or cmd /c
77- const expectedCmd = process . platform === 'win32' ? 'cmd' : 'sh' ;
78- const expectedArgs = process . platform === 'win32'
79- ? [ '/c' , 'node seed.js --force' ]
80- : [ '-c' , 'node seed.js --force' ] ;
85+ await command . run ( { script : 'my-auth:seed' , args : [ '--force' ] } ) ;
8186
87+ // Module scripts run via npm run scriptName inside module dir
8288 expect ( spawnMock ) . toHaveBeenCalledWith (
83- expectedCmd ,
84- expectedArgs ,
85- expect . anything ( )
89+ 'npm' ,
90+ [ 'run' , 'seed' , '--' , '--force' ] ,
91+ expect . objectContaining ( {
92+ cwd : expect . stringContaining ( path . join ( 'modules' , 'my-auth' ) )
93+ } )
8694 ) ;
8795 } ) ;
8896} ) ;
0 commit comments