Skip to content

Commit a07d513

Browse files
authored
fix(run): only match correct INPUT files, not any possible metadatas (#951)
1 parent 740bf39 commit a07d513

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/lib/consts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export const LOCAL_CONFIG_NAME = 'actor.json';
4949

5050
export const LOCAL_CONFIG_PATH = join(ACTOR_SPECIFICATION_FOLDER, LOCAL_CONFIG_NAME);
5151

52-
export const INPUT_FILE_REG_EXP = new RegExp(`^${KEY_VALUE_STORE_KEYS.INPUT}\\..*`);
52+
export const INPUT_FILE_REG_EXP = new RegExp(`(^${KEY_VALUE_STORE_KEYS.INPUT}(?:\\.[^.]+)?$)`);
5353

5454
export const SUPPORTED_NODEJS_VERSION = pkg.engines.node;
5555

test/local/lib/utils.test.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { existsSync, writeFileSync } from 'node:fs';
22
import { join } from 'node:path';
33

4+
import { INPUT_FILE_REG_EXP } from '../../../src/lib/consts.js';
45
import { execWithLog } from '../../../src/lib/exec.js';
56
import { ensureFolderExistsSync } from '../../../src/lib/files.js';
67
import { createActZip, getActorLocalFilePaths } from '../../../src/lib/utils.js';
@@ -78,4 +79,22 @@ describe('Utils', () => {
7879
);
7980
});
8081
});
82+
83+
describe('input file regex', () => {
84+
const validFiles = ['INPUT', 'INPUT.json', 'INPUT.bin'];
85+
86+
const invalidFiles = ['INPUT_', 'INPUT.__metadata__.json'];
87+
88+
validFiles.forEach((file) => {
89+
it(`should match ${file}`, () => {
90+
expect(!!file.match(INPUT_FILE_REG_EXP)).toBeTruthy();
91+
});
92+
});
93+
94+
invalidFiles.forEach((file) => {
95+
it(`should not match ${file}`, () => {
96+
expect(!!file.match(INPUT_FILE_REG_EXP)).toBeFalsy();
97+
});
98+
});
99+
});
81100
});

0 commit comments

Comments
 (0)