diff --git a/lib/index.js b/lib/index.js index 2c99a9a..3ebb33a 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,6 +1,6 @@ import * as system from './system.js'; import { abiToNodeRange, // eslint-disable-line no-duplicate-imports - toFancyArch, toFancyPlatform } from './system.js'; + hostPlatform, knownArchs, toFancyArch, toFancyPlatform } from './system.js'; import { localPlace, remotePlace } from './places.js'; import { log, wasReported } from './log.js'; import build from './build.js'; @@ -54,8 +54,15 @@ export async function need ({ if (await download(remote, downloaded)) return downloaded; downloadFailed = true; } - if (downloadFailed) log.info('Not found in GitHub releases. Building from source...'); - if (forceBuild) log.info('Building base binary from source:', path.basename(built)); + if (downloadFailed) log.info('Not found in GitHub releases'); + log.info('Building base binary from source:', path.basename(built)); + if (hostPlatform !== platform) { + throw wasReported(`Not able to build for '${platform}' here, only for '${hostPlatform}'`); + } + if (knownArchs.indexOf(arch) < 0) { + throw wasReported(`Unknown arch '${arch}'. Specify ${knownArchs.join(', ')}`); + } + await build(nodeVersion, arch, built); return built; }