diff --git a/__tests__/commands/run.js b/__tests__/commands/run.js index 1912e76413..ba691cc1eb 100644 --- a/__tests__/commands/run.js +++ b/__tests__/commands/run.js @@ -71,8 +71,7 @@ test('lists all available commands with no arguments', (): Promise => { return runRun({}, [], 'no-args', (config, reporter): ?Promise => { const rprtr = new reporters.BufferReporter({stdout: null, stdin: null}); const scripts = ['build', 'prestart', 'start']; - // Notice `cat-names` is below twice as there is a bug with output duplication - const bins = ['cat-names', 'cat-names']; + const bins = ['cat-names']; // Emulate run output rprtr.error(rprtr.lang('commandNotSpecified')); diff --git a/src/cli/commands/run.js b/src/cli/commands/run.js index 56b7b215c1..53828c5b54 100644 --- a/src/cli/commands/run.js +++ b/src/cli/commands/run.js @@ -30,14 +30,18 @@ export async function run( const pkg = await config.readManifest(config.cwd); const scripts = map(); const binCommands = []; + const visitedBinFolders = new Set(); let pkgCommands = []; for (const registry of Object.keys(registries)) { const binFolder = path.join(config.cwd, config.registries[registry].folder, '.bin'); - if (await fs.exists(binFolder)) { - for (const name of await fs.readdir(binFolder)) { - binCommands.push(name); - scripts[name] = `"${path.join(binFolder, name)}"`; + if (!visitedBinFolders.has(binFolder)) { + if (await fs.exists(binFolder)) { + for (const name of await fs.readdir(binFolder)) { + binCommands.push(name); + scripts[name] = `"${path.join(binFolder, name)}"`; + } } + visitedBinFolders.add(binFolder); } } if (pkg.scripts) {