Skip to content

Commit

Permalink
Move the code out into a separate for-loop
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisGorbachev committed Nov 24, 2016
1 parent b52d0bc commit a968fd0
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/cli/commands/run.js
Expand Up @@ -19,6 +19,7 @@ import map from '../../util/map.js';

const leven = require('leven');
const path = require('path');
const _ = require('lodash');

export async function run(
config: Config,
Expand All @@ -30,18 +31,18 @@ export async function run(
const pkg = await config.readManifest(config.cwd);
const scripts = map();
const binCommands = [];
const visitedBinFolders = [];
let binFolders = [];
let pkgCommands = [];
for (const registry of Object.keys(registries)) {
const binFolder = path.join(config.cwd, config.registries[registry].folder, '.bin');
if (!visitedBinFolders.includes(binFolder)) {
if (await fs.exists(binFolder)) {
for (const name of await fs.readdir(binFolder)) {
binCommands.push(name);
scripts[name] = `"${path.join(binFolder, name)}"`;
}
binFolders.push(path.join(config.cwd, config.registries[registry].folder, '.bin'));
}
binFolders = _.uniq(binFolders);
for (const binFolder of binFolders) {
if (await fs.exists(binFolder)) {
for (const name of await fs.readdir(binFolder)) {
binCommands.push(name);
scripts[name] = `"${path.join(binFolder, name)}"`;
}
visitedBinFolders.push(binFolder);
}
}
if (pkg.scripts) {
Expand Down

0 comments on commit a968fd0

Please sign in to comment.