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

Commit

Permalink
Build: Produces identifiable binary name.
Browse files Browse the repository at this point in the history
The new format is:
{platform}-{arch}-{runtime}-{major.minor}
where major and minor version belong to
the runtime.

Related Issue: #655.
PR URL: #657.
  • Loading branch information
am11 committed Feb 10, 2015
1 parent 01ca5e2 commit a919a7a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 6 deletions.
7 changes: 5 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var fs = require('fs'),
path = require('path');
path = require('path'),
utils = require('./utils');

/**
* Get binding
Expand All @@ -8,7 +9,8 @@ var fs = require('fs'),
*/

function getBinding() {
var name = process.platform + '-' + process.arch;
var name = utils.getBinaryIdentifiableName();

var candidates = [
path.join(__dirname, '..', 'build', 'Release', 'binding.node'),
path.join(__dirname, '..', 'build', 'Debug', 'binding.node'),
Expand Down Expand Up @@ -255,6 +257,7 @@ module.exports.renderSync = function(options) {
/**
* API Info
*
* @api public
*/

module.exports.info = function() {
Expand Down
28 changes: 28 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var semver = require('semver'),
runtimeVersion = semver.parse(process.version);

/**
* Get Runtime Name
*
* @api private
*/

function getRuntimeName() {
return process.execPath
.split(/[\\/]+/).pop()
.split('.')[0];
}

/**
* Get unique name of binary for current platform
*
* @api public
*/

module.exports.getBinaryIdentifiableName = function() {
return process.platform + '-' +
process.arch + '-' +
runtime + '-' +
runtimeVersion.major + '.' +
runtimeVersion.minor;
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"replace-ext": "0.0.1",
"request": "^2.53.0",
"sass-graph": "^1.0.3",
"semver": "^4.2.2",
"shelljs": "^0.3.0"
},
"devDependencies": {
Expand Down
5 changes: 3 additions & 2 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var fs = require('fs'),
path = require('path'),
spawn = require('child_process').spawn,
mkdir = require('mkdirp'),
Mocha = require('mocha');
Mocha = require('mocha'),
utils = require('../lib/utils');

/**
* After build
Expand Down Expand Up @@ -109,7 +110,7 @@ function parseArgs(args) {
*/

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

if (options.force || process.env.SASS_FORCE_BUILD) {
return build(options);
Expand Down
5 changes: 3 additions & 2 deletions scripts/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ var fs = require('fs'),
path = require('path'),
request = require('request'),
mkdirp = require('mkdirp'),
exec = require('shelljs').exec;
exec = require('shelljs').exec,
utils = require('../lib/utils');

/**
* Download file, if succeeds save, if not delete
Expand Down Expand Up @@ -76,7 +77,7 @@ function applyProxy(options, cb) {
*/

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

fs.exists(path.join(__dirname, '..', 'vendor', name), function (exists) {
if (exists) {
Expand Down

0 comments on commit a919a7a

Please sign in to comment.