From c965ffe7fdd87617d94114634b04e0c968ae0796 Mon Sep 17 00:00:00 2001 From: Igor Klopov Date: Sun, 4 Sep 2016 16:09:48 +0300 Subject: [PATCH] stop when incompatible platform or unknown arch --- lib/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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; }