Skip to content

Commit 0784c07

Browse files
committed
fix: cucumber fails
1 parent 162b157 commit 0784c07

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

features/test-implementations/1.setup.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ Given<TestWorld>(/the local actor is pushed to the Apify platform/i, { timeout:
243243
pushedActorIds.push(this.testActor.name);
244244
} else {
245245
// This throws on errors
246-
result.unwrap();
246+
const err = result.unwrapErr();
247+
248+
throw new Error(`Failed to push actor: ${err.message}`);
247249
}
248250
});

src/lib/command-framework/apify-command.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
201201
}
202202

203203
private async _run(parseResult: ParseResult) {
204-
const { values: rawFlags, positionals: rawArgs } = parseResult;
204+
const { values: rawFlags, positionals: rawArgs, tokens: rawTokens } = parseResult;
205205

206206
if (rawFlags.help) {
207207
this.ctor.printHelp();
@@ -261,7 +261,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
261261
return;
262262
}
263263

264-
this._parseFlags(rawFlags);
264+
this._parseFlags(rawFlags, rawTokens);
265265

266266
try {
267267
await this.run();
@@ -326,7 +326,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
326326
return flagKey;
327327
}
328328

329-
private _parseFlags(rawFlags: ParseResult['values']) {
329+
private _parseFlags(rawFlags: ParseResult['values'], rawTokens: ParseResult['tokens']) {
330330
if (!this.ctor.flags) {
331331
return;
332332
}
@@ -347,6 +347,10 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
347347

348348
const camelCasedName = camelCaseString(baseFlagName);
349349

350+
const usedShortFormOfTheFlag = rawTokens.some(
351+
(token) => token.kind === 'option' && token.name === baseFlagName,
352+
);
353+
350354
if (builderData.exclusive?.length) {
351355
const existingExclusiveFlags = exclusiveFlagMap.get(baseFlagName) ?? new Set();
352356

@@ -409,6 +413,11 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
409413
rawFlag = rawFlag[0]! as string | boolean;
410414
}
411415

416+
// -i='{"foo":"bar"}'
417+
if (usedShortFormOfTheFlag && typeof rawFlag === 'string' && rawFlag.startsWith('=')) {
418+
rawFlag = rawFlag.slice(1);
419+
}
420+
412421
if (typeof rawFlag !== 'undefined') {
413422
switch (builderData.flagTag) {
414423
case 'boolean': {
@@ -578,6 +587,7 @@ export abstract class ApifyCommand<T extends typeof BuiltApifyCommand = typeof B
578587
allowNegative: true,
579588
allowPositionals: true,
580589
strict: true,
590+
tokens: true,
581591
options: {
582592
help: helpFlagDefinition,
583593
} as {
@@ -796,6 +806,7 @@ export async function internalRunCommand<Cmd extends typeof BuiltApifyCommand>(
796806
const rawObject: ParseResult = {
797807
positionals: [],
798808
values: {},
809+
tokens: [],
799810
};
800811

801812
let positionalIndex = 0;

0 commit comments

Comments
 (0)