Allow to use execute command with workflows that do not have an ID

This commit is contained in:
Jan Oberhauser 2022-01-16 14:04:42 +01:00
parent ba6822c4ac
commit 7efb73053d
2 changed files with 9 additions and 3 deletions

View file

@ -2,7 +2,12 @@
/* eslint-disable no-console */ /* eslint-disable no-console */
import { promises as fs } from 'fs'; import { promises as fs } from 'fs';
import { Command, flags } from '@oclif/command'; import { Command, flags } from '@oclif/command';
import { BinaryDataManager, IBinaryDataConfig, UserSettings } from 'n8n-core'; import {
BinaryDataManager,
IBinaryDataConfig,
UserSettings,
PLACEHOLDER_EMPTY_WORKFLOW_ID,
} from 'n8n-core';
import { INode, LoggerProxy } from 'n8n-workflow'; import { INode, LoggerProxy } from 'n8n-workflow';
import { import {
@ -96,8 +101,8 @@ export class Execute extends Command {
console.info(`The file "${flags.file}" does not contain valid workflow data.`); console.info(`The file "${flags.file}" does not contain valid workflow data.`);
return; return;
} }
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
workflowId = workflowData.id!.toString(); workflowId = workflowData.id ? workflowData.id.toString() : PLACEHOLDER_EMPTY_WORKFLOW_ID;
} }
// Wait till the database is ready // Wait till the database is ready

View file

@ -6,5 +6,6 @@ export const USER_FOLDER_ENV_OVERWRITE = 'N8N_USER_FOLDER';
export const USER_SETTINGS_FILE_NAME = 'config'; export const USER_SETTINGS_FILE_NAME = 'config';
export const USER_SETTINGS_SUBFOLDER = '.n8n'; export const USER_SETTINGS_SUBFOLDER = '.n8n';
export const PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKOWN__'; export const PLACEHOLDER_EMPTY_EXECUTION_ID = '__UNKOWN__';
export const PLACEHOLDER_EMPTY_WORKFLOW_ID = '__EMPTY__';
export const TUNNEL_SUBDOMAIN_ENV = 'N8N_TUNNEL_SUBDOMAIN'; export const TUNNEL_SUBDOMAIN_ENV = 'N8N_TUNNEL_SUBDOMAIN';
export const WAIT_TIME_UNLIMITED = '3000-01-01T00:00:00.000Z'; export const WAIT_TIME_UNLIMITED = '3000-01-01T00:00:00.000Z';