Skip to content

Commit f5f05cd

Browse files
committed
Build: Produces identifiable binary name.
The new format is: {platform}-{arch}-{runtime}-{major.minor} where major and minor version belong to the runtime. Related Issue: sass#655. PR URL: sass#657.
1 parent 01ca5e2 commit f5f05cd

File tree

5 files changed

+40
-6
lines changed

5 files changed

+40
-6
lines changed

lib/index.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
var fs = require('fs'),
2-
path = require('path');
2+
path = require('path'),
3+
utils = require('./utils');
34

45
/**
56
* Get binding
@@ -8,7 +9,8 @@ var fs = require('fs'),
89
*/
910

1011
function getBinding() {
11-
var name = process.platform + '-' + process.arch;
12+
var name = utils.getBinaryIdentifiableName();
13+
1214
var candidates = [
1315
path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
1416
path.join(__dirname, '..', 'build', 'Debug', 'binding.node'),
@@ -255,6 +257,7 @@ module.exports.renderSync = function(options) {
255257
/**
256258
* API Info
257259
*
260+
* @api public
258261
*/
259262

260263
module.exports.info = function() {

lib/utils.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
var semver = require('semver'),
2+
runtimeVersion = semver.parse(process.version);
3+
4+
/**
5+
* Get Runtime Name
6+
*
7+
* @api private
8+
*/
9+
10+
function getRuntimeName() {
11+
return process.execPath
12+
.split(/[\\/]+/).pop()
13+
.split('.')[0];
14+
}
15+
16+
/**
17+
* Get unique name of binary for current platform
18+
*
19+
* @api public
20+
*/
21+
22+
module.exports.getBinaryIdentifiableName = function() {
23+
return process.platform + '-' +
24+
process.arch + '-' +
25+
runtime + '-' +
26+
runtimeVersion.major + '.' +
27+
runtimeVersion.minor;
28+
}

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"replace-ext": "0.0.1",
5757
"request": "^2.53.0",
5858
"sass-graph": "^1.0.3",
59+
"semver": "^4.2.2",
5960
"shelljs": "^0.3.0"
6061
},
6162
"devDependencies": {

scripts/build.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var fs = require('fs'),
22
path = require('path'),
33
spawn = require('child_process').spawn,
44
mkdir = require('mkdirp'),
5-
Mocha = require('mocha');
5+
Mocha = require('mocha'),
6+
utils = require('../lib/utils');
67

78
/**
89
* After build
@@ -109,7 +110,7 @@ function parseArgs(args) {
109110
*/
110111

111112
function testBinary(options) {
112-
options.bin = options.platform + '-' + options.arch;
113+
options.bin = utils.getBinaryIdentifiableName();
113114

114115
if (options.force || process.env.SASS_FORCE_BUILD) {
115116
return build(options);

scripts/install.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ var fs = require('fs'),
22
path = require('path'),
33
request = require('request'),
44
mkdirp = require('mkdirp'),
5-
exec = require('shelljs').exec;
5+
exec = require('shelljs').exec
6+
utils = require('../lib/utils');
67

78
/**
89
* Download file, if succeeds save, if not delete
@@ -76,7 +77,7 @@ function applyProxy(options, cb) {
7677
*/
7778

7879
function exists() {
79-
var name = process.platform + '-' + process.arch;
80+
var name = utils.getBinaryIdentifiableName();
8081

8182
fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) {
8283
if (exists) {

0 commit comments

Comments
 (0)