term 'download' -> 'fetch'. to match '-f' option instead of '-d'
This commit is contained in:
parent
cda2ceab7d
commit
b85086dab3
@ -6,16 +6,15 @@ import { need } from './index.js';
|
||||
|
||||
async function main () {
|
||||
const argv = minimist(process.argv.slice(2), {
|
||||
string: [ 'n', 'p', 'a', 'd', 'b' ]
|
||||
string: [ 'n', 'p', 'a', 'f', 'b' ]
|
||||
});
|
||||
const nodeRange = argv.n || argv._.shift();
|
||||
const platform = argv.p || argv._.shift();
|
||||
const arch = argv.a || argv._.shift();
|
||||
// TODO d->f because -d means --debug
|
||||
const forceDownload = argv.d;
|
||||
const forceFetch = argv.f;
|
||||
const forceBuild = argv.b;
|
||||
const local = await need({ nodeRange, platform,
|
||||
arch, forceDownload, forceBuild });
|
||||
arch, forceFetch, forceBuild });
|
||||
log.info(local);
|
||||
}
|
||||
|
||||
|
||||
18
lib/index.js
18
lib/index.js
@ -12,7 +12,7 @@ import semver from 'semver';
|
||||
import { version } from '../package.json';
|
||||
|
||||
export async function need (opts = {}) {
|
||||
let { nodeRange, platform, arch, forceDownload, forceBuild } = opts;
|
||||
let { nodeRange, platform, arch, forceFetch, forceBuild } = opts;
|
||||
if (!nodeRange) throw wasReported('nodeRange not specified');
|
||||
if (!platform) throw wasReported('platform not specified');
|
||||
if (!arch) throw wasReported('arch not specified');
|
||||
@ -34,26 +34,26 @@ export async function need (opts = {}) {
|
||||
throw wasReported(`No available node version satisfies '${opts.nodeRange}'`);
|
||||
}
|
||||
const nodeVersion = nodeVersions.pop();
|
||||
const downloaded = localPlace({ from: 'downloaded', arch, nodeVersion, platform, version });
|
||||
const fetched = localPlace({ from: 'fetched', arch, nodeVersion, platform, version });
|
||||
const built = localPlace({ from: 'built', arch, nodeVersion, platform, version });
|
||||
const remote = remotePlace({ arch, nodeVersion, platform, version });
|
||||
|
||||
let downloadFailed;
|
||||
let fetchFailed;
|
||||
if (!forceBuild) {
|
||||
if (await exists(downloaded)) return downloaded;
|
||||
if (await exists(fetched)) return fetched;
|
||||
}
|
||||
if (!forceDownload) {
|
||||
if (!forceFetch) {
|
||||
if (await exists(built)) {
|
||||
if (forceBuild) log.info('Reusing base binaries built locally:', built);
|
||||
return built;
|
||||
}
|
||||
}
|
||||
if (!forceBuild) {
|
||||
log.info('Downloading base binaries to:', path.dirname(downloaded));
|
||||
if (await download(remote, downloaded)) return downloaded;
|
||||
downloadFailed = true;
|
||||
log.info('Fetching base binaries to:', path.dirname(fetched));
|
||||
if (await download(remote, fetched)) return fetched;
|
||||
fetchFailed = true;
|
||||
}
|
||||
if (downloadFailed) {
|
||||
if (fetchFailed) {
|
||||
log.info('Not found in GitHub releases:', JSON.stringify(remote));
|
||||
}
|
||||
log.info('Building base binary from source:', path.basename(built));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user