Skip to content

Commit

Permalink
Code: Resolves symbolic link.
Browse files Browse the repository at this point in the history
On Windows, process.execPath does not
get resolved symlink path. This commit
fixes the issue.

Related Issue: nodejs/node#851.
PR URL: sass#668.
  • Loading branch information
am11 committed Feb 15, 2015
1 parent b0435cb commit bca06fd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
22 changes: 15 additions & 7 deletions lib/extensions.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
var semver = require('semver'),
runtimeVersion = semver.parse(process.version);
runtimeVersion = semver.parse(process.version),
fs = require('fs');

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

function getRuntimeName() {
var runtime = process.execPath
function getRuntimeInfo() {
var execPath = fs.realpathSync(process.execPath); // resolve symbolic link

var runtime = execPath
.split(/[\\/]+/).pop()
.split('.').shift();

return runtime === 'nodejs' ? 'node' : runtime;
runtime = runtime === 'nodejs' ? 'node' : runtime;

return {
name: name,
execPath: execPath
};
}

/**
Expand All @@ -24,10 +32,10 @@ function getRuntimeName() {
function getBinaryIdentifiableName() {
return [process.platform, '-',
process.arch, '-',
getRuntimeName(), '-',
process.runtime.name, '-',
runtimeVersion.major, '.',
runtimeVersion.minor].join('');
}

process.runtime = getRuntimeName();
process.runtime = getRuntimeInfo();
process.sassBinaryName = getBinaryIdentifiableName();
6 changes: 5 additions & 1 deletion scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ function afterBuild(options) {
*/

function build(options) {
var proc = spawn(process.execPath, ['node_modules/pangyp/bin/node-gyp', 'rebuild'].concat(options.args), {
var arguments = ['node_modules/pangyp/bin/node-gyp', 'rebuild'].concat(options.args);

console.log(['Building:', process.runtime.execPath].concat(arguments).join(' '));

var proc = spawn(process.runtime.execPath, arguments, {
stdio: [0, 1, 2]
});

Expand Down

0 comments on commit bca06fd

Please sign in to comment.