@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
55import type { IWorld } from '@cucumber/cucumber' ;
66import { Result } from '@sapphire/result' ;
77import type { ApifyClient } from 'apify-client' ;
8- import { type Options , type ExecaError , type Result as ExecaResult , execaNode } from 'execa' ;
8+ import { type ExecaError , execaNode , type Options , type Result as ExecaResult } from 'execa' ;
99
1010type DynamicOptions = {
1111 - readonly [ P in keyof Options ] : Options [ P ] ;
@@ -49,8 +49,8 @@ export interface TestWorld<Parameters = unknown[]> extends IWorld<Parameters> {
4949 */
5050export const ProjectRoot = new URL ( '../../' , import . meta. url ) ;
5151
52- export const DevRunFile = new URL ( './src/entrypoints/apify.ts' , ProjectRoot ) ;
53-
52+ export const ApifyDevRunFile = new URL ( './src/entrypoints/apify.ts' , ProjectRoot ) ;
53+ export const ActorDevRunFile = new URL ( './src/entrypoints/actor.ts' , ProjectRoot ) ;
5454export const TestTmpRoot = new URL ( './test/tmp/' , ProjectRoot ) ;
5555
5656await mkdir ( TestTmpRoot , { recursive : true } ) ;
@@ -80,18 +80,20 @@ export async function executeCommand({
8080 // step 1: get the first element, and make sure it starts with `apify`
8181 const [ command ] = commandToRun ;
8282
83- if ( ! command . startsWith ( 'apify' ) ) {
83+ if ( ! command . startsWith ( 'apify' ) && ! command . startsWith ( 'actor' ) ) {
8484 // TODO: maybe try to parse these commands out and provide stdin that way, but for now, its better to get the writer to use the existing rules
8585 if ( command . startsWith ( 'echo' ) || command . startsWith ( 'jo' ) ) {
8686 throw new RangeError (
8787 `When writing a test case, please use the "given the following input provided via standard input" rule for providing standard input to the command you're testing.\nReceived: ${ command } ` ,
8888 ) ;
8989 }
9090
91- throw new RangeError ( `Command must start with 'apify', received: ${ command } ` ) ;
91+ throw new RangeError ( `Command must start with 'apify' or 'actor' , received: ${ command } ` ) ;
9292 }
9393
94- const cleanCommand = command . replace ( / ^ a p i f y / , '' ) . trim ( ) ;
94+ const devRunFile = command . startsWith ( 'apify' ) ? ApifyDevRunFile : ActorDevRunFile ;
95+
96+ const cleanCommand = command . replace ( / ^ a p i f y | a c t o r / , '' ) . trim ( ) ;
9597
9698 const options : DynamicOptions = {
9799 cwd,
@@ -138,7 +140,7 @@ export async function executeCommand({
138140 > ( async ( ) => {
139141 const process = execaNode (
140142 tsxCli ,
141- [ fileURLToPath ( DevRunFile ) , ...commandArguments ] ,
143+ [ fileURLToPath ( devRunFile ) , ...commandArguments ] ,
142144 options as { cwd : typeof cwd ; input : typeof stdin } ,
143145 ) ;
144146
0 commit comments