Skip to content
This repository was archived by the owner on Jul 24, 2024. It is now read-only.

Commit cb80edd

Browse files
committed
Fix build scripts to actually use passed arguments
1 parent 33a32c3 commit cb80edd

File tree

6 files changed

+2645
-152
lines changed

6 files changed

+2645
-152
lines changed

lib/constants.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
var Runtimes = exports.Runtimes = {
2+
NODE: 0,
3+
NODEJS: 1,
4+
IOJS: 2,
5+
ELECTRON: 3
6+
};
7+
exports.RuntimeNames = [
8+
'Node',
9+
'Node.js',
10+
'io.js',
11+
'Electron'
12+
];
13+
exports.ModuleVersions = {
14+
11: [Runtimes.NODE, '0.10.x'],
15+
14: [Runtimes.NODE, '0.12.x'],
16+
42: [Runtimes.IOJS, '1.x'],
17+
43: [Runtimes.IOJS, '1.1.x'],
18+
44: [Runtimes.IOJS, '2.x'],
19+
45: [Runtimes.IOJS, '3.x'],
20+
49: [Runtimes.ELECTRON, '1.3.x'],
21+
50: [Runtimes.ELECTRON, '1.4.x'],
22+
53: [Runtimes.ELECTRON, '1.6.x'],
23+
46: [Runtimes.NODEJS, '4.x'],
24+
47: [Runtimes.NODEJS, '5.x'],
25+
48: [Runtimes.NODEJS, '6.x'],
26+
51: [Runtimes.NODEJS, '7.x'],
27+
57: [Runtimes.NODEJS, '8.x'],
28+
59: [Runtimes.NODEJS, '9.x'],
29+
64: [Runtimes.NODEJS, '10.x'],
30+
67: [Runtimes.NODEJS, '11.x']
31+
};
32+
exports.DefaultOptions = {
33+
jobs: 1,
34+
target: process.version,
35+
force: process.env.SASS_FORCE_BUILD || false,
36+
arch: process.arch,
37+
debug: process.config.target_defaults ? process.config.target_defaults.default_configuration === 'Debug' : false,
38+
modulesVersion: process.versions.modules
39+
};

lib/extensions.js

Lines changed: 15 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ var eol = require('os').EOL,
88
mkdir = require('mkdirp'),
99
path = require('path'),
1010
defaultBinaryDir = path.join(__dirname, '..', 'vendor'),
11+
Constants = require('./constants'),
1112
trueCasePathSync = require('true-case-path');
1213

1314
/**
@@ -59,26 +60,8 @@ function getHumanArchitecture(arch) {
5960
* @api public
6061
*/
6162
function getHumanNodeVersion(abi) {
62-
switch (parseInt(abi || process.versions.modules, 10)) {
63-
case 11: return 'Node 0.10.x';
64-
case 14: return 'Node 0.12.x';
65-
case 42: return 'io.js 1.x';
66-
case 43: return 'io.js 1.1.x';
67-
case 44: return 'io.js 2.x';
68-
case 45: return 'io.js 3.x';
69-
case 46: return 'Node.js 4.x';
70-
case 47: return 'Node.js 5.x';
71-
case 48: return 'Node.js 6.x';
72-
case 49: return 'Electron 1.3.x';
73-
case 50: return 'Electron 1.4.x';
74-
case 51: return 'Node.js 7.x';
75-
case 53: return 'Electron 1.6.x';
76-
case 57: return 'Node.js 8.x';
77-
case 59: return 'Node.js 9.x';
78-
case 64: return 'Node.js 10.x';
79-
case 67: return 'Node.js 11.x';
80-
default: return false;
81-
}
63+
var Version = Constants.ModuleVersions[parseInt(abi)];
64+
return Version ? Constants.RuntimeNames[Version[0]] + ' ' + Version[1] : false;
8265
}
8366

8467
/**
@@ -179,7 +162,7 @@ function getArgument(name, args) {
179162
* @api public
180163
*/
181164

182-
function getBinaryName() {
165+
function getBinaryName(options) {
183166
var binaryName,
184167
variant,
185168
platform = process.platform;
@@ -198,14 +181,11 @@ function getBinaryName() {
198181
platform += '_' + variant;
199182
}
200183

201-
binaryName = [
202-
platform, '-',
203-
process.arch, '-',
204-
process.versions.modules
205-
].join('');
184+
binaryName = platform + '-' + options.arch + '-' + options.modulesVersion;
185+
206186
}
207187

208-
return [binaryName, 'binding.node'].join('_');
188+
return binaryName + '_binding.node';
209189
}
210190

211191
/**
@@ -236,14 +216,14 @@ function getBinaryName() {
236216
* @api public
237217
*/
238218

239-
function getBinaryUrl() {
219+
function getBinaryUrl(options) {
240220
var site = getArgument('--sass-binary-site') ||
241221
process.env.SASS_BINARY_SITE ||
242222
process.env.npm_config_sass_binary_site ||
243223
(pkg.nodeSassConfig && pkg.nodeSassConfig.binarySite) ||
244224
'https://github.com/sass/node-sass/releases/download';
245225

246-
return [site, 'v' + pkg.version, getBinaryName()].join('/');
226+
return [site, 'v' + pkg.version, getBinaryName(options)].join('/');
247227
}
248228

249229
/**
@@ -292,7 +272,7 @@ function getBinaryDir() {
292272
* @api public
293273
*/
294274

295-
function getBinaryPath() {
275+
function getBinaryPath(options) {
296276
var binaryPath;
297277

298278
if (getArgument('--sass-binary-path')) {
@@ -304,10 +284,10 @@ function getBinaryPath() {
304284
} else if (pkg.nodeSassConfig && pkg.nodeSassConfig.binaryPath) {
305285
binaryPath = pkg.nodeSassConfig.binaryPath;
306286
} else {
307-
binaryPath = path.join(getBinaryDir(), getBinaryName().replace(/_(?=binding\.node)/, '/'));
287+
binaryPath = path.join(getBinaryDir(), getBinaryName(options).replace(/_(?=binding\.node)/, '/'));
308288
}
309289

310-
if (process.versions.modules < 46) {
290+
if (options.modulesVersion < 46) {
311291
return binaryPath;
312292
}
313293

@@ -321,7 +301,7 @@ function getBinaryPath() {
321301
/**
322302
* An array of paths suitable for use as a local disk cache of the binding.
323303
*
324-
* @return {[]String} an array of paths
304+
* @return {String[]} an array of paths
325305
* @api public
326306
*/
327307
function getCachePathCandidates() {
@@ -372,12 +352,12 @@ function getBinaryCachePath() {
372352
* @return {String} path to cached binary
373353
* @api public
374354
*/
375-
function getCachedBinary() {
355+
function getCachedBinary(options) {
376356
var i,
377357
cachePath,
378358
cacheBinary,
379359
cachePathCandidates = getCachePathCandidates(),
380-
binaryName = getBinaryName();
360+
binaryName = getBinaryName(options);
381361

382362
for (i = 0; i < cachePathCandidates.length; i++) {
383363
cachePath = path.join(cachePathCandidates[i], pkg.name, pkg.version);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"read-yaml": "^1.0.0",
8383
"rimraf": "^2.5.2",
8484
"sass-spec": "https://github.com/sass/sass-spec.git#dc2d573",
85-
"unique-temp-dir": "^1.0.0"
85+
"unique-temp-dir": "^1.0.0",
86+
"yargs": "^13.2.2"
8687
}
8788
}

0 commit comments

Comments
 (0)