Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --no-bin-links flag - fixes #929 #1651

Merged
merged 1 commit into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
7 changes: 5 additions & 2 deletions 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 All @@ -243,7 +246,7 @@ export default class Config {
generateHardModulePath(pkg: ?PackageReference, ignoreLocation?: ?boolean): string {
invariant(this.cacheFolder, 'No package root');
invariant(pkg, 'Undefined package');

if (pkg.location && !ignoreLocation) {
return pkg.location;
}
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