mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
feat: Add support for reading ids from file with executeBatch command (#3008)
This commit is contained in:
parent
c0611a0b81
commit
5658593df4
2
.github/workflows/test-workflows.yml
vendored
2
.github/workflows/test-workflows.yml
vendored
|
@ -73,7 +73,7 @@ jobs:
|
||||||
shell: bash
|
shell: bash
|
||||||
-
|
-
|
||||||
name: Run tests
|
name: Run tests
|
||||||
run: n8n/packages/cli/bin/n8n executeBatch --shallow --skipList=test-workflows/skipList.txt --shortOutput --concurrency=16 --compare=test-workflows/snapshots
|
run: n8n/packages/cli/bin/n8n executeBatch --shallow --ids=test-workflows/safeList.txt --shortOutput --concurrency=16 --compare=test-workflows/snapshots
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
N8N_ENCRYPTION_KEY: ${{secrets.ENCRYPTION_KEY}}
|
N8N_ENCRYPTION_KEY: ${{secrets.ENCRYPTION_KEY}}
|
||||||
|
|
|
@ -76,7 +76,8 @@ export class ExecuteBatch extends Command {
|
||||||
description: 'Toggles on displaying all errors and debug messages.',
|
description: 'Toggles on displaying all errors and debug messages.',
|
||||||
}),
|
}),
|
||||||
ids: flags.string({
|
ids: flags.string({
|
||||||
description: 'Specifies workflow IDs to get executed, separated by a comma.',
|
description:
|
||||||
|
'Specifies workflow IDs to get executed, separated by a comma or a file containing the ids',
|
||||||
}),
|
}),
|
||||||
concurrency: flags.integer({
|
concurrency: flags.integer({
|
||||||
default: 1,
|
default: 1,
|
||||||
|
@ -244,17 +245,26 @@ export class ExecuteBatch extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags.ids !== undefined) {
|
if (flags.ids !== undefined) {
|
||||||
|
if (fs.existsSync(flags.ids)) {
|
||||||
|
const contents = fs.readFileSync(flags.ids, { encoding: 'utf-8' });
|
||||||
|
ids.push(...contents.split(',').map((id) => parseInt(id.trim(), 10)));
|
||||||
|
} else {
|
||||||
const paramIds = flags.ids.split(',');
|
const paramIds = flags.ids.split(',');
|
||||||
const re = /\d+/;
|
const re = /\d+/;
|
||||||
const matchedIds = paramIds.filter((id) => re.exec(id)).map((id) => parseInt(id.trim(), 10));
|
const matchedIds = paramIds
|
||||||
|
.filter((id) => re.exec(id))
|
||||||
|
.map((id) => parseInt(id.trim(), 10));
|
||||||
|
|
||||||
if (matchedIds.length === 0) {
|
if (matchedIds.length === 0) {
|
||||||
console.log(`The parameter --ids must be a list of numeric IDs separated by a comma.`);
|
console.log(
|
||||||
|
`The parameter --ids must be a list of numeric IDs separated by a comma or a file with this content.`,
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ids.push(...matchedIds);
|
ids.push(...matchedIds);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flags.skipList !== undefined) {
|
if (flags.skipList !== undefined) {
|
||||||
if (fs.existsSync(flags.skipList)) {
|
if (fs.existsSync(flags.skipList)) {
|
||||||
|
|
Loading…
Reference in a new issue