Skip to content

Commit d88fffe

Browse files
author
Sebastian McKenzie
committed
remove cli flags we wont support and add support for --no-lockfile flag
1 parent 170cb22 commit d88fffe

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/cli/commands/install.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ function shouldWriteLockfileIfExists(flags: Object, args: Array<string>): boolea
368368
*/
369369

370370
function shouldWriteLockfile(flags: Object, args: Array<string>): boolean {
371+
if (!flags.lockfile) {
372+
return false;
373+
}
374+
371375
if (hasSaveFlags(flags)) {
372376
// we should write a new lockfile as we're introducing new dependencies
373377
return true;
@@ -390,13 +394,8 @@ export function setFlags(commander: Object) {
390394
commander.option("-O, --save-optional", "save package to your `optionalDependencies`");
391395
commander.option("-E, --save-exact", "");
392396
commander.option("-T, --save-tilde", "");
393-
commander.option("--tag [tag]", ""); // TODO
394-
commander.option("--dry-run", ""); // TODO
395-
commander.option("-f, --force", ""); // TODO
396-
commander.option("-g, --global", ""); // TODO
397-
commander.option("--link"); // TODO
398397
commander.option("--no-optional"); // TODO
399-
commander.option("--no-lockfile"); // TODO
398+
commander.option("--no-lockfile");
400399
commander.option("--init-mirror", "initialise local package mirror and copy module tarballs");
401400
}
402401

@@ -406,10 +405,16 @@ export async function run(
406405
flags: Object,
407406
args: Array<string>
408407
): Promise<void> {
409-
let lockfile = await Lockfile.fromDirectory(config.cwd, reporter, {
410-
strictIfPresent: isStrictLockfile(flags, args),
411-
save: hasSaveFlags(flags) || flags.initMirror
412-
});
408+
let lockfile;
409+
if (flags.lockfile) {
410+
lockfile = await Lockfile.fromDirectory(config.cwd, reporter, {
411+
strictIfPresent: isStrictLockfile(flags, args),
412+
save: hasSaveFlags(flags) || flags.initMirror
413+
});
414+
} else {
415+
lockfile = new Lockfile;
416+
}
417+
413418
let install = new Install("install", flags, args, config, reporter, lockfile);
414419
return install.init();
415420
}

src/lockfile/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export { default as parse } from "./parse";
2424
export { default as stringify } from "./stringify";
2525

2626
export default class Lockfile {
27-
constructor(cache: ?Object, strict?: boolean, save?: boolean, source?: string) {
27+
constructor(cache?: ?Object, strict?: boolean, save?: boolean, source?: string) {
2828
this.strict = !!strict;
2929
this.source = source || "";
3030
this.cache = cache;

0 commit comments

Comments
 (0)