How to use the global-npm.prefix function in global-npm

To help you get started, we’ve selected a few global-npm examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github maxleiko / npmi / npmi.js View on Github external
return function (err, view) {
            if (err) {
                // reset npm.prefix to saved value
                npm.prefix = savedPrefix;
                err.code = VIEW_ERR;
                return callback(err);
            }

            // npm view success
            var latestVersion = Object.keys(view)[0];
            if ((typeof latestVersion !== 'undefined') && (latestVersion === installedVersion)) {
                // reset npm.prefix to saved value
                npm.prefix = savedPrefix;
                return callback();
            } else {
                npm.commands.install(installPath, [name+'@'+latestVersion], installCallback);
            }
        }
    }
github maxleiko / npmi / npmi.js View on Github external
function loadCallback(err) {
        if (err) {
            err.code = LOAD_ERR;
            return callback(err);
        }

        // npm loaded successfully
        savedPrefix = npm.prefix; // save current npm.prefix
        npm.prefix = installPath; // change npm.prefix to given installPath
        if (!name) {
            // just want to do an "npm install" where a package.json is
            npm.commands.install(installPath, [], installCallback);

        } else if (localInstall) {
            if (forceInstall) {
                // local install won't work with version specified
                npm.commands.install(installPath, [name], installCallback);
            } else {
                // check if there is already a local install of this module
                fs.readFile(path.resolve(name, 'package.json'), 'utf8', function (err, sourcePkgData) {
                    if (err) {
                        // reset npm.prefix to saved value
                        npm.prefix = savedPrefix;
                        callback(err);
github maxleiko / npmi / npmi.js View on Github external
function installCallback(err, result) {
        // reset npm.prefix to saved value
        npm.prefix = savedPrefix;

        if (err) {
            err.code = INSTALL_ERR;
        }

        callback(err, result);
    }

global-npm

Require global npm as a local node module.

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis