src/extensibility/node/package-validator.js
function findCommonPrefix(extractDir, callback) {
    fs.readdir(extractDir, function (err, files) {
        ignoredFolders.forEach(function (folder) {
            var index = files.indexOf(folder);
            if (index !== -1) {
                files.splice(index, 1);
            }
        });
        if (err) {
            callback(err);
        } else if (files.length === 1) {
            var name = files[0];
            if (fs.statSync(path.join(extractDir, name)).isDirectory()) {
                callback(null, name);
            } else {
                callback(null, "");
            }
        } else {
            callback(null, "");
        }
    });
}
function findCommonPrefix(extractDir, callback) {
    fs.readdir(extractDir, function (err, files) {
        ignoredFolders.forEach(function (folder) {
            var index = files.indexOf(folder);
            if (index !== -1) {
                files.splice(index, 1);
            }
        });
        if (err) {
            callback(err);
        } else if (files.length === 1) {
            var name = files[0];
            if (fs.statSync(path.join(extractDir, name)).isDirectory()) {
                callback(null, name);
            } else {
                callback(null, "");
            }
        } else {
            callback(null, "");
        }
    });
}
function findCommonPrefix ( extractDir , callback ) { fs . readdir ( extractDir , function ( err , files ) { ignoredFolders . forEach ( function ( folder ) { var index = files . indexOf ( folder ) ; if ( index !== - 1 ) { files . splice ( index , 1 ) ; } } ) ; if ( err ) { callback ( err ) ; } else if ( files . length === 1 ) { var name = files [ 0 ] ; if ( fs . statSync ( path . join ( extractDir , name ) ) . isDirectory ( ) ) { callback ( null , name ) ; } else { callback ( null , "" ) ; } } else { callback ( null , "" ) ; } } ) ; }
Finds the common prefix, if any, for the files in a package file.

In some package files, all of the files are contained in a subdirectory, and this function
will identify that directory if it exists.

@param {string} extractDir directory into which the package was extracted
@param {function(Error, string)} callback function to accept err, commonPrefix (which will be "" if there is none)
Finds the common prefix if any for the files in a package file .