@@ -178,4 +178,69 @@ describe('runAutorunExecutor', () => {
178178 expect ( warnMessage ) . toContain ( 'DryRun execution of:' ) ;
179179 expect ( warnMessage ) . toContain ( 'npx @code-pushup/cli' ) ;
180180 } ) ;
181+
182+ it ( 'should extract --import from NODE_OPTIONS and pass as direct argument when bin is set' , async ( ) => {
183+ const { command } = await runAutorunExecutor (
184+ {
185+ bin : 'packages/cli/src/index.ts' ,
186+ env : {
187+ NODE_OPTIONS : '--import tsx' ,
188+ TSX_TSCONFIG_PATH : 'tsconfig.base.json' ,
189+ } ,
190+ } ,
191+ executorContext ( 'utils' ) ,
192+ ) ;
193+
194+ const commandWithoutAnsi = removeColorCodes ( command || '' ) ;
195+ expect ( commandWithoutAnsi ) . toMatch (
196+ 'node --import tsx packages/cli/src/index.ts' ,
197+ ) ;
198+ expect ( executeProcessSpy ) . toHaveBeenCalledWith (
199+ expect . objectContaining ( {
200+ command : 'node' ,
201+ args : expect . arrayContaining ( [
202+ '--import' ,
203+ 'tsx' ,
204+ 'packages/cli/src/index.ts' ,
205+ ] ) ,
206+ env : expect . objectContaining ( {
207+ TSX_TSCONFIG_PATH : 'tsconfig.base.json' ,
208+ } ) ,
209+ } ) ,
210+ ) ;
211+ // NODE_OPTIONS should be removed since it only contained --import
212+ expect ( executeProcessSpy . mock . calls [ 0 ] ?. [ 0 ] ?. env ) . not . toHaveProperty (
213+ 'NODE_OPTIONS' ,
214+ ) ;
215+ } ) ;
216+
217+ it ( 'should preserve other NODE_OPTIONS when extracting --import' , async ( ) => {
218+ const { command } = await runAutorunExecutor (
219+ {
220+ bin : 'packages/cli/src/index.ts' ,
221+ env : {
222+ NODE_OPTIONS : '--max-old-space-size=4096 --import tsx' ,
223+ } ,
224+ } ,
225+ executorContext ( 'utils' ) ,
226+ ) ;
227+
228+ const commandWithoutAnsi = removeColorCodes ( command || '' ) ;
229+ expect ( commandWithoutAnsi ) . toMatch (
230+ 'node --import tsx packages/cli/src/index.ts' ,
231+ ) ;
232+ expect ( executeProcessSpy ) . toHaveBeenCalledWith (
233+ expect . objectContaining ( {
234+ command : 'node' ,
235+ args : expect . arrayContaining ( [
236+ '--import' ,
237+ 'tsx' ,
238+ 'packages/cli/src/index.ts' ,
239+ ] ) ,
240+ env : expect . objectContaining ( {
241+ NODE_OPTIONS : '--max-old-space-size=4096' ,
242+ } ) ,
243+ } ) ,
244+ ) ;
245+ } ) ;
181246} ) ;
0 commit comments