src/extensibility/node/package-validator.js
function extractAndValidateFiles(zipPath, extractDir, options, callback) {
    var unzipper = new DecompressZip(zipPath);
    unzipper.on("error", function (err) {
        // General error to report for problems reading the file
        callback(null, {
            errors: [[Errors.INVALID_ZIP_FILE, zipPath, err]]
        });
        return;
    });

    unzipper.on("extract", function (log) {
        findCommonPrefix(extractDir, function (err, commonPrefix) {
            if (err) {
                callback(err, null);
                return;
            }
            var packageJSON = path.join(extractDir, commonPrefix, "package.json");
            validatePackageJSON(zipPath, packageJSON, options, function (err, errors, metadata) {
                if (err) {
                    callback(err, null);
                    return;
                }
                var mainJS  = path.join(extractDir, commonPrefix, "main.js"),
                    isTheme = metadata && metadata.theme;

                // Throw missing main.js file only for non-theme extensions
                if (!isTheme && !fs.existsSync(mainJS)) {
                    errors.push([Errors.MISSING_MAIN, zipPath, mainJS]);
                }

                var npmOptions = ['--production'];

                if (options.proxy) {
                    npmOptions.push('--proxy ' + options.proxy);
                }

                if (process.platform.startsWith('win')) {
                    // On Windows force a 32 bit build until nodejs 64 bit is supported.
                    npmOptions.push('--arch=ia32');
                    npmOptions.push('--npm_config_arch=ia32');
                    npmOptions.push('--npm_config_target_arch=ia32');
                }

                performNpmInstallIfRequired(npmOptions, {
                    errors: errors,
                    metadata: metadata,
                    commonPrefix: commonPrefix,
                    extractDir: extractDir
                }, callback);
            });
        });
    });

    unzipper.extract({
        path: extractDir,
        filter: function (file) {
            return file.type !== "SymbolicLink";
        }
    });
}
function extractAndValidateFiles(zipPath, extractDir, options, callback) {
    var unzipper = new DecompressZip(zipPath);
    unzipper.on("error", function (err) {
        // General error to report for problems reading the file
        callback(null, {
            errors: [[Errors.INVALID_ZIP_FILE, zipPath, err]]
        });
        return;
    });

    unzipper.on("extract", function (log) {
        findCommonPrefix(extractDir, function (err, commonPrefix) {
            if (err) {
                callback(err, null);
                return;
            }
            var packageJSON = path.join(extractDir, commonPrefix, "package.json");
            validatePackageJSON(zipPath, packageJSON, options, function (err, errors, metadata) {
                if (err) {
                    callback(err, null);
                    return;
                }
                var mainJS  = path.join(extractDir, commonPrefix, "main.js"),
                    isTheme = metadata && metadata.theme;

                // Throw missing main.js file only for non-theme extensions
                if (!isTheme && !fs.existsSync(mainJS)) {
                    errors.push([Errors.MISSING_MAIN, zipPath, mainJS]);
                }

                var npmOptions = ['--production'];

                if (options.proxy) {
                    npmOptions.push('--proxy ' + options.proxy);
                }

                if (process.platform.startsWith('win')) {
                    // On Windows force a 32 bit build until nodejs 64 bit is supported.
                    npmOptions.push('--arch=ia32');
                    npmOptions.push('--npm_config_arch=ia32');
                    npmOptions.push('--npm_config_target_arch=ia32');
                }

                performNpmInstallIfRequired(npmOptions, {
                    errors: errors,
                    metadata: metadata,
                    commonPrefix: commonPrefix,
                    extractDir: extractDir
                }, callback);
            });
        });
    });

    unzipper.extract({
        path: extractDir,
        filter: function (file) {
            return file.type !== "SymbolicLink";
        }
    });
}
function extractAndValidateFiles ( zipPath , extractDir , options , callback ) { var unzipper = new DecompressZip ( zipPath ) ; unzipper . on ( "error" , function ( err ) { // General error to report for problems reading the file callback ( null , { errors : [ [ Errors . INVALID_ZIP_FILE , zipPath , err ] ] } ) ; return ; } ) ; unzipper . on ( "extract" , function ( log ) { findCommonPrefix ( extractDir , function ( err , commonPrefix ) { if ( err ) { callback ( err , null ) ; return ; } var packageJSON = path . join ( extractDir , commonPrefix , "package.json" ) ; validatePackageJSON ( zipPath , packageJSON , options , function ( err , errors , metadata ) { if ( err ) { callback ( err , null ) ; return ; } var mainJS = path . join ( extractDir , commonPrefix , "main.js" ) , isTheme = metadata && metadata . theme ; // Throw missing main.js file only for non-theme extensions if ( ! isTheme && ! fs . existsSync ( mainJS ) ) { errors . push ( [ Errors . MISSING_MAIN , zipPath , mainJS ] ) ; } var npmOptions = [ '--production' ] ; if ( options . proxy ) { npmOptions . push ( '--proxy ' + options . proxy ) ; } if ( process . platform . startsWith ( 'win' ) ) { // On Windows force a 32 bit build until nodejs 64 bit is supported. npmOptions . push ( '--arch=ia32' ) ; npmOptions . push ( '--npm_config_arch=ia32' ) ; npmOptions . push ( '--npm_config_target_arch=ia32' ) ; } performNpmInstallIfRequired ( npmOptions , { errors : errors , metadata : metadata , commonPrefix : commonPrefix , extractDir : extractDir } , callback ) ; } ) ; } ) ; } ) ; unzipper . extract ( { path : extractDir , filter : function ( file ) { return file . type !== "SymbolicLink" ; } } ) ; }
Extracts the package into the given directory and then validates it.

@param {string} zipPath path to package zip file
@param {string} extractDir directory to extract package into
@param {Object} options validation options
@param {function(Error, {errors: Array, metadata: Object, commonPrefix: string, extractDir: string})} callback function to call with the result
Extracts the package into the given directory and then validates it .