From 84b56eb48e727389189c517598aadadd6f2ccf23 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: Mon, 12 Sep 2022 16:31:49 +0200 Subject: [PATCH] fix(cli): avoid scanning unnecessary directories on windows (#4082) fixes #4007 Ticket: N8N-4603 --- packages/cli/commands/import/credentials.ts | 2 +- packages/cli/commands/import/workflow.ts | 2 +- packages/cli/src/LoadNodesAndCredentials.ts | 4 +++- .../nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts | 1 - 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/cli/commands/import/credentials.ts b/packages/cli/commands/import/credentials.ts index da6453a650..9a0170ba59 100644 --- a/packages/cli/commands/import/credentials.ts +++ b/packages/cli/commands/import/credentials.ts @@ -95,7 +95,7 @@ export class ImportCredentialsCommand extends Command { inputPath = inputPath.replace(/\/$/g, ''); - const files = await glob(`${inputPath}/*.json`); + const files = await glob('*.json', { cwd: inputPath }); totalImported = files.length; diff --git a/packages/cli/commands/import/workflow.ts b/packages/cli/commands/import/workflow.ts index 34a5c97b8c..5b08a4d0ed 100644 --- a/packages/cli/commands/import/workflow.ts +++ b/packages/cli/commands/import/workflow.ts @@ -117,7 +117,7 @@ export class ImportWorkflowsCommand extends Command { inputPath = inputPath.replace(/\/$/g, ''); - const files = await glob(`${inputPath}/*.json`); + const files = await glob('*.json', { cwd: inputPath }); totalImported = files.length; diff --git a/packages/cli/src/LoadNodesAndCredentials.ts b/packages/cli/src/LoadNodesAndCredentials.ts index f302638d07..7062aad8b0 100644 --- a/packages/cli/src/LoadNodesAndCredentials.ts +++ b/packages/cli/src/LoadNodesAndCredentials.ts @@ -493,7 +493,9 @@ class LoadNodesAndCredentialsClass { * @returns {Promise} */ async loadDataFromDirectory(setPackageName: string, directory: string): Promise { - const files = await glob(path.join(directory, '**/*.@(node|credentials).js')); + const files = await glob('**/*.@(node|credentials).js', { + cwd: directory, + }); for (const filePath of files) { const [fileName, type] = path.parse(filePath).name.split('.'); diff --git a/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts b/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts index 3741d9344e..4c9ec040e3 100644 --- a/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts +++ b/packages/nodes-base/nodes/ReadBinaryFiles/ReadBinaryFiles.node.ts @@ -1,7 +1,6 @@ import { IExecuteFunctions } from 'n8n-core'; import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow'; import glob from 'fast-glob'; -import path from 'path'; import { readFile as fsReadFile } from 'fs/promises';