brackets-npm-registry
Version:
Install your extensions into Brackets using npm
61 lines (52 loc) • 1.78 kB
JavaScript
/* eslint strict:0 */
;
/*
returns current node process path
*/
var _require = require('bluebird');
var promisify = _require.promisify;
var promisifyAll = _require.promisifyAll;
var fs = promisifyAll(require('fs-extra'));
var path = require('path');
var which = promisify(require('which'));
var result = undefined;
module.exports = function () {
if (result) {
return result;
}
result = which('node')['catch'](function () {
return null;
}) // ignore the errors
.then(function (whichNode) {
// use the node from process.execPath so any compiled dependencies use same version of node as brackets
// we need a symlink if process.execPath is different from node/node.exe
var currentName = path.basename(process.execPath);
var desiredName = process.platform === 'win32' ? 'node.exe' : 'node';
if (currentName === desiredName) {
return process.execPath;
}
var nodeSymlinkDir = path.resolve(__dirname, 'nodeSymlinkDir');
var nodeLinkPath = path.resolve(nodeSymlinkDir, desiredName);
return fs.ensureDirAsync(nodeSymlinkDir).then(function () {
return fs.lstatAsync(nodeLinkPath);
})['catch'](function () {
return null;
}) // ignore the errors
.then(function (stat) {
if (stat && stat.isSymbolicLink()) {
return fs.unlinkAsync(nodeLinkPath);
}
}).then(function () {
return fs.symlinkAsync(process.execPath, nodeLinkPath);
}).then(function () {
return nodeLinkPath;
})['catch'](function (err) {
if (whichNode) {
return whichNode;
}
throw err;
});
});
return result;
};
//# sourceMappingURL=C:\Users\Zaggi\AppData\Roaming\Brackets-Electron\extensions\user\brackets-npm-registry\dist//node/node-ensure.js.map