Skip to content

Commit

Permalink
Add --no-bin-links flag - fixes yarnpkg#929 (yarnpkg#1651)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian McKenzie committed Nov 3, 2016
1 parent 41fe065 commit 96fbeea
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -341,6 +342,7 @@ function onUnexpectedError(err: Error) {

//
config.init({
binLinks: commander.binLinks,
modulesFolder: commander.modulesFolder,
globalFolder: commander.globalFolder,
cacheFolder: commander.cacheFolder,
Expand Down
5 changes: 4 additions & 1 deletion src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -80,6 +81,7 @@ export default class Config {
offline: boolean;
preferOffline: boolean;
ignorePlatform: boolean;
binLinks: boolean;

//
linkedModules: Array<string>;
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 9 additions & 7 deletions src/package-linker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 96fbeea

Please sign in to comment.