Skip to content

Commit

Permalink
Fail prepack-dev if there are no tarballs at all
Browse files Browse the repository at this point in the history
Summary:
If you try to build an npm in dev mode without adding any binaries,
a useless package is successfully created. This diff instead causes
it to fail if you don't add at least one tarball.

Reviewed By: mhorowitz

Differential Revision: D16606325

fbshipit-source-id: a81a1dc3e314b4c698f9ae35ec1fc74b761a2cfe
  • Loading branch information
willholen authored and facebook-github-bot committed Aug 1, 2019
1 parent cab0dc7 commit 339d5dd
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions npm/fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,15 +101,20 @@ async function unpack(tarball, destdir) {
// In dev mode, it's likely cli tarballs for other platforms will
// be missing. Just log it and move on.
console.warn("Ignoring missing tarball in dev mode", err);
return;
return false;
} else {
throw err;
}
}
return true;
};

async function unpackAll(files) {
await Promise.all(files.map(x => unpack(x.name, x.dest)));
var results = await Promise.all(files.map(x => unpack(x.name, x.dest)));
if (!results.some(c => c)) {
var names = inputs.map(c => c.name).join(", ");
throw "No tarballs found. Please build or download at least one of: " + names;
}
}

var inputs = [
Expand Down

0 comments on commit 339d5dd

Please sign in to comment.