core/server/data/importer/index.js
function (directory) {
        // Globs match root level only
        var extMatches = glob.sync(this.getExtensionGlob(this.getExtensions(), ROOT_ONLY), {cwd: directory}),
            dirMatches = glob.sync(this.getDirectoryGlob(this.getDirectories(), ROOT_ONLY), {cwd: directory}),
            extMatchesAll;

        // There is no base directory
        if (extMatches.length > 0 || dirMatches.length > 0) {
            return;
        }
        // There is a base directory, grab it from any ext match
        extMatchesAll = glob.sync(
            this.getExtensionGlob(this.getExtensions(), ALL_DIRS), {cwd: directory}
        );
        if (extMatchesAll.length < 1 || extMatchesAll[0].split('/') < 1) {
            throw new common.errors.ValidationError({message: common.i18n.t('errors.data.importer.index.invalidZipFileBaseDirectory')});
        }

        return extMatchesAll[0].split('/')[0];
    }
function (directory) {
        // Globs match root level only
        var extMatches = glob.sync(this.getExtensionGlob(this.getExtensions(), ROOT_ONLY), {cwd: directory}),
            dirMatches = glob.sync(this.getDirectoryGlob(this.getDirectories(), ROOT_ONLY), {cwd: directory}),
            extMatchesAll;

        // There is no base directory
        if (extMatches.length > 0 || dirMatches.length > 0) {
            return;
        }
        // There is a base directory, grab it from any ext match
        extMatchesAll = glob.sync(
            this.getExtensionGlob(this.getExtensions(), ALL_DIRS), {cwd: directory}
        );
        if (extMatchesAll.length < 1 || extMatchesAll[0].split('/') < 1) {
            throw new common.errors.ValidationError({message: common.i18n.t('errors.data.importer.index.invalidZipFileBaseDirectory')});
        }

        return extMatchesAll[0].split('/')[0];
    }
function ( directory ) { // Globs match root level only var extMatches = glob . sync ( this . getExtensionGlob ( this . getExtensions ( ) , ROOT_ONLY ) , { cwd : directory } ) , dirMatches = glob . sync ( this . getDirectoryGlob ( this . getDirectories ( ) , ROOT_ONLY ) , { cwd : directory } ) , extMatchesAll ; // There is no base directory if ( extMatches . length > 0 || dirMatches . length > 0 ) { return ; } // There is a base directory, grab it from any ext match extMatchesAll = glob . sync ( this . getExtensionGlob ( this . getExtensions ( ) , ALL_DIRS ) , { cwd : directory } ) ; if ( extMatchesAll . length < 1 || extMatchesAll [ 0 ] . split ( '/' ) < 1 ) { throw new common . errors . ValidationError ( { message : common . i18n . t ( 'errors.data.importer.index.invalidZipFileBaseDirectory' ) } ) ; } return extMatchesAll [ 0 ] . split ( '/' ) [ 0 ] ; }
Get the name of the single base directory if there is one, else return an empty string
@param {String} directory
@returns {Promise (String)}
Get the name of the single base directory if there is one else return an empty string