src/extensibility/node/npm-installer.js
function performNpmInstallIfRequired(npmOptions, validationResult, callback) {

    function finish() {
        callback(null, validationResult);
    }

    var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
    var packageJson;

    try {
        packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
    } catch (e) {
        packageJson = null;
    }

    if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
        return finish();
    }

    _performNpmInstall(installDirectory, npmOptions, function (err) {
        if (err) {
            validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
        }
        finish();
    });
}
function performNpmInstallIfRequired(npmOptions, validationResult, callback) {

    function finish() {
        callback(null, validationResult);
    }

    var installDirectory = path.join(validationResult.extractDir, validationResult.commonPrefix);
    var packageJson;

    try {
        packageJson = fs.readJsonSync(path.join(installDirectory, "package.json"));
    } catch (e) {
        packageJson = null;
    }

    if (!packageJson || !packageJson.dependencies || !Object.keys(packageJson.dependencies).length) {
        return finish();
    }

    _performNpmInstall(installDirectory, npmOptions, function (err) {
        if (err) {
            validationResult.errors.push([Errors.NPM_INSTALL_FAILED, err.toString()]);
        }
        finish();
    });
}
function performNpmInstallIfRequired ( npmOptions , validationResult , callback ) { function finish ( ) { callback ( null , validationResult ) ; } var installDirectory = path . join ( validationResult . extractDir , validationResult . commonPrefix ) ; var packageJson ; try { packageJson = fs . readJsonSync ( path . join ( installDirectory , "package.json" ) ) ; } catch ( e ) { packageJson = null ; } if ( ! packageJson || ! packageJson . dependencies || ! Object . keys ( packageJson . dependencies ) . length ) { return finish ( ) ; } _performNpmInstall ( installDirectory , npmOptions , function ( err ) { if ( err ) { validationResult . errors . push ( [ Errors . NPM_INSTALL_FAILED , err . toString ( ) ] ) ; } finish ( ) ; } ) ; }
Checks package.json of the extracted extension for npm dependencies
and runs npm install when required.
@param {Object} validationResult return value of the validation procedure
@param {Function} callback function to be called after the end of validation procedure
Checks package . json of the extracted extension for npm dependencies and runs npm install when required .