Commit 6dc6c632 by Adeel

Code: Resolves symbolic link.

On Windows, process.execPath does not
get resolved symlink path. This commit
fixes the issue.

Related Issue: iojs/io.js#851.
PR URL: #668.
parent b0435cbd
var semver = require('semver'), 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 * @api private
*/ */
function getRuntimeName() { function getRuntimeInfo() {
var runtime = process.execPath var execPath = fs.realpathSync(process.execPath); // resolve symbolic link
var runtime = execPath
.split(/[\\/]+/).pop() .split(/[\\/]+/).pop()
.split('.').shift(); .split('.').shift();
return runtime === 'nodejs' ? 'node' : runtime; runtime = runtime === 'nodejs' ? 'node' : runtime;
return {
name: runtime,
execPath: execPath
};
} }
/** /**
...@@ -24,10 +32,10 @@ function getRuntimeName() { ...@@ -24,10 +32,10 @@ function getRuntimeName() {
function getBinaryIdentifiableName() { function getBinaryIdentifiableName() {
return [process.platform, '-', return [process.platform, '-',
process.arch, '-', process.arch, '-',
getRuntimeName(), '-', process.runtime.name, '-',
runtimeVersion.major, '.', runtimeVersion.major, '.',
runtimeVersion.minor].join(''); runtimeVersion.minor].join('');
} }
process.runtime = getRuntimeName(); process.runtime = getRuntimeInfo();
process.sassBinaryName = getBinaryIdentifiableName(); process.sassBinaryName = getBinaryIdentifiableName();
...@@ -50,7 +50,11 @@ function afterBuild(options) { ...@@ -50,7 +50,11 @@ function afterBuild(options) {
*/ */
function build(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] stdio: [0, 1, 2]
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment