distinguish built and downloaded binaries. fixes #1
This commit is contained in:
parent
2ec1425c6f
commit
349d41954d
12
lib/index.js
12
lib/index.js
@ -30,21 +30,23 @@ export async function need ({
|
||||
throw wasReported(`No available node version satisfies '${nodeRange}'`);
|
||||
}
|
||||
const nodeVersion = nodeVersions.pop();
|
||||
const local = localPlace({ arch, nodeVersion, platform, version });
|
||||
const downloaded = localPlace({ from: 'downloaded', arch, nodeVersion, platform, version });
|
||||
const built = localPlace({ from: 'built', arch, nodeVersion, platform, version });
|
||||
|
||||
let downloadFailed;
|
||||
if (!forceDownload && !forceBuild) {
|
||||
if (await exists(local)) return local;
|
||||
if (await exists(downloaded)) return downloaded;
|
||||
if (await exists(built)) return built;
|
||||
}
|
||||
if (!forceBuild) {
|
||||
log.info('Downloading base binaries to \'~/.pkg-cache\'...');
|
||||
const remote = remotePlace({ arch, nodeVersion, platform, version });
|
||||
if (await download(remote, local)) return local;
|
||||
if (await download(remote, downloaded)) return downloaded;
|
||||
downloadFailed = true;
|
||||
}
|
||||
if (downloadFailed) log.info('Not found in GitHub releases. Building...');
|
||||
await build(nodeVersion, arch, local);
|
||||
return local;
|
||||
await build(nodeVersion, arch, built);
|
||||
return built;
|
||||
}
|
||||
|
||||
export { system };
|
||||
|
||||
@ -21,12 +21,14 @@ export async function main () {
|
||||
for (const nodeVersion in patchesJson) {
|
||||
for (const targetArch of targetArchs) {
|
||||
if (isBrokenBuild(nodeVersion, targetArch)) continue;
|
||||
const local = localPlace({ arch: targetArch, nodeVersion, platform: hostPlatform, version });
|
||||
const local = localPlace({ from: 'built', arch: targetArch,
|
||||
nodeVersion, platform: hostPlatform, version });
|
||||
const short = path.basename(local);
|
||||
log.info(`Building ${short}...`);
|
||||
await build(nodeVersion, targetArch, local);
|
||||
log.info(`Uploading ${short}...`);
|
||||
const remote = remotePlace({ arch: targetArch, nodeVersion, platform: hostPlatform, version });
|
||||
const remote = remotePlace({ arch: targetArch,
|
||||
nodeVersion, platform: hostPlatform, version });
|
||||
try {
|
||||
await upload(local, remote);
|
||||
} catch (error) {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{
|
||||
"localPlace": "~/.pkg-cache/{version}/base-{nodeVersion}-{platform}-{arch}",
|
||||
"localPlace": "~/.pkg-cache/{version}/{from}-{nodeVersion}-{platform}-{arch}",
|
||||
"remotePlace": "base-{nodeVersion}-{platform}-{arch}"
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user