-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathruntimePaths.js
95 lines (91 loc) · 2.71 KB
/
runtimePaths.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'use strict'
const assert = require('assert')
const semver = require('semver')
const NODE_MIRROR = process.env.NVM_NODEJS_ORG_MIRROR || 'https://nodejs.org/dist'
const ELECTRON_MIRROR = process.env.ELECTRON_MIRROR || 'https://artifacts.electronjs.org/headers/dist'
const runtimePaths = {
node: function (targetOptions) {
if (semver.lt(targetOptions.runtimeVersion, '4.0.0')) {
return {
externalPath: NODE_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
},
],
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: false,
}
} else {
return {
externalPath: NODE_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isArm64 ? 'win-arm64' : targetOptions.isX64 ? 'win-x64' : 'win-x86',
name: targetOptions.runtime + '.lib',
},
],
tarPath: targetOptions.runtime + '-v' + targetOptions.runtimeVersion + '-headers.tar.gz',
headerOnly: true,
}
}
},
nw: function (targetOptions) {
if (semver.gte(targetOptions.runtimeVersion, '0.13.0')) {
return {
externalPath: 'https://node-webkit.s3.amazonaws.com/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
},
{
dir: targetOptions.isX64 ? 'x64' : '',
name: 'node.lib',
},
],
tarPath: 'nw-headers-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: false,
}
}
return {
externalPath: 'https://node-webkit.s3.amazonaws.com/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isX64 ? 'x64' : '',
name: targetOptions.runtime + '.lib',
},
],
tarPath: 'nw-headers-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: false,
}
},
electron: function (targetOptions) {
return {
externalPath: ELECTRON_MIRROR + '/v' + targetOptions.runtimeVersion + '/',
winLibs: [
{
dir: targetOptions.isArm64 ? 'arm64' : targetOptions.isX64 ? 'x64' : '',
name: 'node.lib',
},
],
tarPath: 'node' + '-v' + targetOptions.runtimeVersion + '.tar.gz',
headerOnly: semver.gte(targetOptions.runtimeVersion, '4.0.0-alpha'),
}
},
get: function (targetOptions) {
assert(targetOptions && typeof targetOptions === 'object')
const runtime = targetOptions.runtime
const func = runtimePaths[runtime]
let paths
if (typeof func === 'function') {
paths = func(targetOptions)
if (paths && typeof paths === 'object') {
return paths
}
}
throw new Error('Unknown runtime: ' + runtime)
},
}
module.exports = runtimePaths