@@ -8,6 +8,7 @@ var eol = require('os').EOL,
8
8
mkdir = require ( 'mkdirp' ) ,
9
9
path = require ( 'path' ) ,
10
10
defaultBinaryDir = path . join ( __dirname , '..' , 'vendor' ) ,
11
+ Constants = require ( './constants' ) ,
11
12
trueCasePathSync = require ( 'true-case-path' ) ;
12
13
13
14
/**
@@ -59,26 +60,8 @@ function getHumanArchitecture(arch) {
59
60
* @api public
60
61
*/
61
62
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 ;
82
65
}
83
66
84
67
/**
@@ -179,7 +162,7 @@ function getArgument(name, args) {
179
162
* @api public
180
163
*/
181
164
182
- function getBinaryName ( ) {
165
+ function getBinaryName ( options ) {
183
166
var binaryName ,
184
167
variant ,
185
168
platform = process . platform ;
@@ -198,14 +181,11 @@ function getBinaryName() {
198
181
platform += '_' + variant ;
199
182
}
200
183
201
- binaryName = [
202
- platform , '-' ,
203
- process . arch , '-' ,
204
- process . versions . modules
205
- ] . join ( '' ) ;
184
+ binaryName = platform + '-' + options . arch + '-' + options . modulesVersion ;
185
+
206
186
}
207
187
208
- return [ binaryName , 'binding .node'] . join ( '_' ) ;
188
+ return binaryName + '_binding .node';
209
189
}
210
190
211
191
/**
@@ -236,14 +216,14 @@ function getBinaryName() {
236
216
* @api public
237
217
*/
238
218
239
- function getBinaryUrl ( ) {
219
+ function getBinaryUrl ( options ) {
240
220
var site = getArgument ( '--sass-binary-site' ) ||
241
221
process . env . SASS_BINARY_SITE ||
242
222
process . env . npm_config_sass_binary_site ||
243
223
( pkg . nodeSassConfig && pkg . nodeSassConfig . binarySite ) ||
244
224
'https://github.com/sass/node-sass/releases/download' ;
245
225
246
- return [ site , 'v' + pkg . version , getBinaryName ( ) ] . join ( '/' ) ;
226
+ return [ site , 'v' + pkg . version , getBinaryName ( options ) ] . join ( '/' ) ;
247
227
}
248
228
249
229
/**
@@ -292,7 +272,7 @@ function getBinaryDir() {
292
272
* @api public
293
273
*/
294
274
295
- function getBinaryPath ( ) {
275
+ function getBinaryPath ( options ) {
296
276
var binaryPath ;
297
277
298
278
if ( getArgument ( '--sass-binary-path' ) ) {
@@ -304,10 +284,10 @@ function getBinaryPath() {
304
284
} else if ( pkg . nodeSassConfig && pkg . nodeSassConfig . binaryPath ) {
305
285
binaryPath = pkg . nodeSassConfig . binaryPath ;
306
286
} else {
307
- binaryPath = path . join ( getBinaryDir ( ) , getBinaryName ( ) . replace ( / _ (? = b i n d i n g \. n o d e ) / , '/' ) ) ;
287
+ binaryPath = path . join ( getBinaryDir ( ) , getBinaryName ( options ) . replace ( / _ (? = b i n d i n g \. n o d e ) / , '/' ) ) ;
308
288
}
309
289
310
- if ( process . versions . modules < 46 ) {
290
+ if ( options . modulesVersion < 46 ) {
311
291
return binaryPath ;
312
292
}
313
293
@@ -321,7 +301,7 @@ function getBinaryPath() {
321
301
/**
322
302
* An array of paths suitable for use as a local disk cache of the binding.
323
303
*
324
- * @return {[]String } an array of paths
304
+ * @return {String[] } an array of paths
325
305
* @api public
326
306
*/
327
307
function getCachePathCandidates ( ) {
@@ -372,12 +352,12 @@ function getBinaryCachePath() {
372
352
* @return {String } path to cached binary
373
353
* @api public
374
354
*/
375
- function getCachedBinary ( ) {
355
+ function getCachedBinary ( options ) {
376
356
var i ,
377
357
cachePath ,
378
358
cacheBinary ,
379
359
cachePathCandidates = getCachePathCandidates ( ) ,
380
- binaryName = getBinaryName ( ) ;
360
+ binaryName = getBinaryName ( options ) ;
381
361
382
362
for ( i = 0 ; i < cachePathCandidates . length ; i ++ ) {
383
363
cachePath = path . join ( cachePathCandidates [ i ] , pkg . name , pkg . version ) ;
0 commit comments