Skip to content

Commit f42b597

Browse files
authored
Merge pull request #95 from bestander/fix-import-pr-issue-77
Fixed scenario for importing a PR with package.json changed
2 parents 229ef3d + bb0173a commit f42b597

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

src/cli/commands/install.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ function isStrictLockfile(flags: Object, args: Array<string>): boolean {
337337
*/
338338

339339
function shouldWriteLockfileIfExists(flags: Object, args: Array<string>): boolean {
340-
if (args.length) {
340+
if (args.length || flags.save) {
341341
return shouldWriteLockfile(flags, args);
342342
} else {
343343
return false;
@@ -386,10 +386,6 @@ export async function run(
386386
flags: Object,
387387
args: Array<string>
388388
): Promise<void> {
389-
if (hasSaveFlags(flags) && !args.length) {
390-
throw new MessageError("Missing package names for --save flags");
391-
}
392-
393389
let lockfile = await Lockfile.fromDirectory(config.cwd, reporter, {
394390
strictIfPresent: isStrictLockfile(flags, args),
395391
save: hasSaveFlags(flags) || flags.initMirror

test/commands/install.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,7 @@ test("uninstall should remove subdependencies", () => {
647647
});
648648
});
649649

650-
// TODO https://github.com/facebook/fbkpm/issues/77
651-
test.failing("[network] install --save should add missing deps to fbkpm and mirror (PR import scenario)",
650+
test("[network] install --save should add missing deps to fbkpm and mirror (PR import scenario)",
652651
async () => {
653652
let mirrorPath = "mirror-for-offline";
654653
let fixture = "install-import-pr";
@@ -668,7 +667,6 @@ async () => {
668667

669668
let lockFileContent = await fs.readFile(path.join(config.cwd, "fbkpm.lock"));
670669
let lockFileLines = lockFileContent.split("\n").filter((line) => !!line);
671-
// TODO error here
672670
assert.equal(lockFileLines.length, 14);
673671
assert.equal(lockFileLines[4].indexOf("mime-db@"), 0);
674672
assert.equal(lockFileLines[8].indexOf("mime-types@2.0.0"), 0);
@@ -679,8 +677,7 @@ async () => {
679677
});
680678
});
681679

682-
// TODO https://github.com/facebook/fbkpm/issues/78
683-
test.failing("[network] install --save should update a dependency to fbkpm and mirror (PR import scenario 2)",
680+
test.only("[network] install --save should update a dependency to fbkpm and mirror (PR import scenario 2)",
684681
async () => {
685682
// mime-types@2.0.0 is saved in local mirror and gets updated to mime-types@2.1.11 via
686683
// a change in package.json,

0 commit comments

Comments
 (0)