UNPKG

1.62 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6exports.remotePlace = exports.localPlace = void 0;
7var semver_1 = require("semver");
8var os_1 = __importDefault(require("os"));
9var path_1 = __importDefault(require("path"));
10var PKG_CACHE_PATH = process.env.PKG_CACHE_PATH;
11var IGNORE_TAG = Boolean(process.env.PKG_IGNORE_TAG);
12var cachePath = PKG_CACHE_PATH || path_1.default.join(os_1.default.homedir(), '.pkg-cache');
13function tagFromVersion(version) {
14 var mj = semver_1.major(version);
15 var mn = semver_1.minor(version);
16 return "v" + mj + "." + mn;
17}
18function localPlace(_a) {
19 var from = _a.from, output = _a.output, version = _a.version, nodeVersion = _a.nodeVersion, platform = _a.platform, arch = _a.arch;
20 var binDir;
21 if (output) {
22 binDir = path_1.default.resolve(output);
23 }
24 else {
25 binDir = IGNORE_TAG
26 ? path_1.default.join(cachePath)
27 : path_1.default.join(cachePath, tagFromVersion(version));
28 }
29 return path_1.default.resolve(binDir, (output ? 'node' : from) + "-" + nodeVersion + "-" + platform + "-" + arch);
30}
31exports.localPlace = localPlace;
32function remotePlace(_a) {
33 var version = _a.version, nodeVersion = _a.nodeVersion, platform = _a.platform, arch = _a.arch;
34 return {
35 tag: tagFromVersion(version),
36 name: "node-" + nodeVersion + "-" + platform + "-" + arch,
37 };
38}
39exports.remotePlace = remotePlace;
40//# sourceMappingURL=places.js.map
\No newline at end of file