From 96fbeea6afb144652a5a05c0ee8571057d78c4b6 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Thu, 3 Nov 2016 16:32:02 +0000 Subject: [PATCH] Add --no-bin-links flag - fixes #929 (#1651) --- src/cli/index.js | 2 ++ src/config.js | 5 ++++- src/package-linker.js | 16 +++++++++------- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/cli/index.js b/src/cli/index.js index 05a7c05d65..e4b0745d65 100644 --- a/src/cli/index.js +++ b/src/cli/index.js @@ -51,6 +51,7 @@ commander.option('--ignore-platform', 'ignore platform checks'); commander.option('--ignore-engines', 'ignore engines check'); commander.option('--ignore-optional', ''); commander.option('--force', 'ignore all caches'); +commander.option('--no-bin-links', "don't generate bin links when setting up packages"); commander.option('--flat', 'only allow one version of a package'); commander.option('--prod, --production', ''); commander.option('--no-lockfile', "don't read or generate a lockfile"); @@ -341,6 +342,7 @@ function onUnexpectedError(err: Error) { // config.init({ + binLinks: commander.binLinks, modulesFolder: commander.modulesFolder, globalFolder: commander.globalFolder, cacheFolder: commander.cacheFolder, diff --git a/src/config.js b/src/config.js index c9126829d3..1f7464564b 100644 --- a/src/config.js +++ b/src/config.js @@ -33,6 +33,7 @@ export type ConfigOptions = { ignoreEngines?: boolean, cafile?: ?string, production?: boolean, + binLinks?: boolean, // Loosely compare semver for invalid cases like "0.01.0" looseSemver?: ?boolean, @@ -80,6 +81,7 @@ export default class Config { offline: boolean; preferOffline: boolean; ignorePlatform: boolean; + binLinks: boolean; // linkedModules: Array; @@ -220,8 +222,9 @@ export default class Config { this.cacheFolder = opts.cacheFolder || constants.MODULE_CACHE_DIRECTORY; this.linkFolder = opts.linkFolder || constants.LINK_REGISTRY_DIRECTORY; this.tempFolder = opts.tempFolder || path.join(this.cacheFolder, '.tmp'); - this.offline = !!opts.offline; this.production = !!opts.production; + this.offline = !!opts.offline; + this.binLinks = !!opts.binLinks; this.ignorePlatform = !!opts.ignorePlatform; this.ignoreScripts = !!opts.ignoreScripts; diff --git a/src/package-linker.js b/src/package-linker.js index 75bd820079..5821673756 100644 --- a/src/package-linker.js +++ b/src/package-linker.js @@ -184,12 +184,14 @@ export default class PackageLinker { }); // - const tickBin = this.reporter.progress(flatTree.length); - await promise.queue(flatTree, async ([dest, {pkg}]) => { - const binLoc = path.join(this.config.cwd, this.config.getFolder(pkg)); - await this.linkBinDependencies(pkg, binLoc); - tickBin(dest); - }, 4); + if (this.config.binLinks) { + const tickBin = this.reporter.progress(flatTree.length); + await promise.queue(flatTree, async ([dest, {pkg}]) => { + const binLoc = path.join(this.config.cwd, this.config.getFolder(pkg)); + await this.linkBinDependencies(pkg, binLoc); + tickBin(dest); + }, 4); + } } resolvePeerModules() { @@ -270,7 +272,7 @@ export default class PackageLinker { const src = this.config.generateHardModulePath(ref); // link bins - if (resolved.bin && Object.keys(resolved.bin).length) { + if (this.config.binLinks && resolved.bin && Object.keys(resolved.bin).length) { const folder = this.config.modulesFolder || path.join(this.config.cwd, this.config.getFolder(resolved)); const binLoc = path.join(folder, '.bin'); await fs.mkdirp(binLoc);