tolerate if no release or asset

This commit is contained in:
igorklopov 2016-08-15 12:17:50 +03:00
parent b6db0dd867
commit 6398d7509c

View File

@ -12,18 +12,16 @@ import { version } from '../package.json';
async function download (remote, local) {
const tag = `v${version}`;
const release = await getRelease(tag);
if (!release) {
throw new Error(`Release ${tag} not found`);
}
if (!release) return false;
const assets = release.assets.filter(({ name }) => {
assert(name);
return name === remote;
});
if (assets.length !== 1) {
throw new Error(`Assets found: ${assets.length}`);
}
if (!assets.length) return false;
assert(assets.length === 1);
const asset = assets[0];
await downloadAsset(asset, local);
return true;
}
export async function need ({
@ -57,8 +55,7 @@ export async function need ({
if (!dontDownload) {
const remote = remotePlace({ arch, nodeVersion, platform, version });
await mkdirp(path.dirname(local));
await download(remote, local);
return local;
if (await download(remote, local)) return local;
}
if (!dontBuild) {
assert(false);