Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function resolveBin (modName, {executable = modName, cwd = process.cwd()} = {}) {
let pathFromWhich
try {
pathFromWhich = fs.realpathSync(which.sync(executable))
} catch (_error) {
// ignore _error
}
try {
const modPkgPath = require.resolve(`${modName}/package.json`)
const modPkgDir = path.dirname(modPkgPath)
const { bin } = require(modPkgPath)
const binPath = typeof bin === 'string' ? bin : bin[executable]
const fullPathToBin = path.join(modPkgDir, binPath)
if (fullPathToBin === pathFromWhich) {
return executable
}
return fullPathToBin.replace(cwd, '.')
} catch (error) {
if (pathFromWhich) {
return executable
function shouldPrependCurrentNodeDirToPATH (opts) {
const cfgsetting = opts.scriptsPrependNodePath
if (cfgsetting === false) return false
if (cfgsetting === true) return true
var isDifferentNodeInPath
var foundExecPath
try {
foundExecPath = which.sync(path.basename(process.execPath), { pathExt: isWindows ? ';' : ':' })
// Apply `fs.realpath()` here to avoid false positives when `node` is a symlinked executable.
isDifferentNodeInPath = fs.realpathSync(process.execPath).toUpperCase() !==
fs.realpathSync(foundExecPath).toUpperCase()
} catch (e) {
isDifferentNodeInPath = true
}
if (cfgsetting === 'warn-only') {
if (isDifferentNodeInPath && !shouldPrependCurrentNodeDirToPATH.hasWarned) {
if (foundExecPath) {
opts.log.warn('lifecycle', 'The node binary used for scripts is', foundExecPath, 'but npm is using', process.execPath, 'itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.')
} else {
opts.log.warn('lifecycle', 'npm is using', process.execPath, 'but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.')
}
shouldPrependCurrentNodeDirToPATH.hasWarned = true
}
/*
* @copyright Copyright (c) Sematext Group, Inc. - All Rights Reserved
*
* @licence SPM for NodeJS is free-to-use, proprietary software.
* THIS IS PROPRIETARY SOURCE CODE OF Sematext Group, Inc. (Sematext)
* This source code may not be copied, reverse engineered, or altered for any purpose.
* This source code is to be used exclusively by users and customers of Sematext.
* Please see the full license (found in LICENSE in this distribution) for details on its license and the licenses of its dependencies.
*/
var which = require('which')
var vmstatCommand = which.sync('vmstat')
var exec = require('child_process').exec
var diskfree = require('node-df')
function vmstatS (callback) {
exec(vmstatCommand + ' -s', function (err, stout, sterr) {
if (err) {
callback(err)
return
}
try {
var lines = stout.split('\n')
lines = lines.map(function (line) { return line.trim()})
if (lines.length >= 21) {
var swapMapping = {
swapUsed: 8,
swapIn: 20,
return tslib_1.__awaiter(this, void 0, void 0, function* () {
let { command } = this.config;
if (command === 'gocode') {
try {
which.sync('gocode');
}
catch (e) {
yield util_1.echoWarning(this.nvim, 'Could not find gocode in $PATH');
this.disabled = true;
return;
}
}
});
}
function getCordovaOrPhonegapCLI() {
var cordovaCLI = 'cordova';
try {
which.sync(cordovaCLI);
return cordovaCLI;
}
catch (e) {
cordovaCLI = 'phonegap';
which.sync(cordovaCLI);
return cordovaCLI;
}
}
exports.getCordovaOrPhonegapCLI = getCordovaOrPhonegapCLI;
fontforge: {},
ttf2eot: {}
};
if (isLinux) {
check.ttf2svg = {};
} else {
check['batik-ttf2svg'] = {};
}
var missing = [];
for (var cmd in check) {
if (check.hasOwnProperty(cmd)) {
try {
commands[cmd] = which(cmd);
} catch(e) {
missing.push(cmd);
}
}
}
if (missing.length) {
if (isLinux) {
var errNPM = [], errAPT = [];
missing.forEach(function(cmd){
if (cmd.indexOf("ttf2") != -1) {
errNPM.push(cmd);
} else{
errAPT.push(cmd);
}
});
self.saveall = function(seconds_delay, callback) {
var params = { cwd: self.env.cwd };
var binary = which.sync('screen');
var FALLBACK_DELAY_SECONDS = 5;
async.series([
async.apply(self.verify, 'exists'),
async.apply(self.verify, 'up'),
function(cb) {
self.property('owner', function(err, result) {
params['uid'] = result['uid'];
params['gid'] = result['gid'];
cb(err);
})
},
function(cb) {
cb(null, child_process.spawn(binary,
['-S', 'mc-{0}'.format(self.server_name),
'-p', '0', '-X', 'eval', 'stuff "save-all\012"'],
sailsExists: function sailsExists() {
try {
which('sails');
return true;
} catch (err) {
return false;
}
},
var throwNotFoundError = function () {
var err = new Error("Cannot find module 'npm'")
err.code = 'MODULE_NOT_FOUND'
throw err
}
try {
var ENV = process.env
if (ENV.GLOBAL_NPM_BIN) {
GLOBAL_NPM_BIN = ENV.GLOBAL_NPM_BIN
} else if (ENV.npm_execpath) {
GLOBAL_NPM_BIN = ENV.npm_execpath
} else if ((ENV.NODENV_VERSION === 'system') && ENV.NODENV_ROOT) {
var trimPath = ENV.PATH.replace(path.join(ENV.NODENV_ROOT, 'shims'), '')
GLOBAL_NPM_BIN = fs.realpathSync(which.sync('npm', { path: trimPath }))
} else {
GLOBAL_NPM_BIN = fs.realpathSync(which.sync('npm'))
}
} catch (e) {
throwNotFoundError()
}
GLOBAL_NPM_PATH = process.env.GLOBAL_NPM_PATH || path.join(
GLOBAL_NPM_BIN,
process.platform === 'win32' ? '../node_modules/npm' : '../..'
)
module.exports = (function () {
try {
var npm = require(GLOBAL_NPM_PATH)
if (npm && Object.keys(npm).length) {
function shouldPrependCurrentNodeDirToPATH() {
var isWindows = process.platform === 'win32'
try {
var foundExecPath = which.sync(path.basename(process.execPath), {
pathExt: isWindows ? ';' : ':'
})
return process.execPath.toUpperCase() !== foundExecPath.toUpperCase()
} catch (e) {
return true
}
}