From 6e04a04852a6b707748a9c2660c240d4023af3ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=A4=95=E0=A4=BE=E0=A4=B0=E0=A4=A4=E0=A5=8B=E0=A4=AB?= =?UTF-8?q?=E0=A5=8D=E0=A4=AB=E0=A5=87=E0=A4=B2=E0=A4=B8=E0=A5=8D=E0=A4=95?= =?UTF-8?q?=E0=A5=8D=E0=A4=B0=E0=A4=BF=E0=A4=AA=E0=A5=8D=E0=A4=9F=E2=84=A2?= Date: Wed, 14 Sep 2022 10:05:28 +0200 Subject: [PATCH] fix(cli): use absolute paths for loading custom nodes and credentials broke after this change https://github.com/n8n-io/n8n/pull/4082 --- packages/cli/commands/import/credentials.ts | 7 ++++--- packages/cli/commands/import/workflow.ts | 7 ++++--- packages/cli/src/LoadNodesAndCredentials.ts | 1 + 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/cli/commands/import/credentials.ts b/packages/cli/commands/import/credentials.ts index 9a0170ba59285..a1fec6b000719 100644 --- a/packages/cli/commands/import/credentials.ts +++ b/packages/cli/commands/import/credentials.ts @@ -93,9 +93,10 @@ export class ImportCredentialsCommand extends Command { inputPath = inputPath.replace(/\\/g, '/'); } - inputPath = inputPath.replace(/\/$/g, ''); - - const files = await glob('*.json', { cwd: inputPath }); + const files = await glob('*.json', { + cwd: inputPath, + absolute: true, + }); totalImported = files.length; diff --git a/packages/cli/commands/import/workflow.ts b/packages/cli/commands/import/workflow.ts index 5b08a4d0ed035..b365829b13e89 100644 --- a/packages/cli/commands/import/workflow.ts +++ b/packages/cli/commands/import/workflow.ts @@ -115,9 +115,10 @@ export class ImportWorkflowsCommand extends Command { inputPath = inputPath.replace(/\\/g, '/'); } - inputPath = inputPath.replace(/\/$/g, ''); - - const files = await glob('*.json', { cwd: inputPath }); + const files = await glob('*.json', { + cwd: inputPath, + absolute: true, + }); totalImported = files.length; diff --git a/packages/cli/src/LoadNodesAndCredentials.ts b/packages/cli/src/LoadNodesAndCredentials.ts index 7062aad8b05eb..f75f289d99743 100644 --- a/packages/cli/src/LoadNodesAndCredentials.ts +++ b/packages/cli/src/LoadNodesAndCredentials.ts @@ -495,6 +495,7 @@ class LoadNodesAndCredentialsClass { async loadDataFromDirectory(setPackageName: string, directory: string): Promise { const files = await glob('**/*.@(node|credentials).js', { cwd: directory, + absolute: true, }); for (const filePath of files) {