function processPath(options) {
    const cwd = (options && options.cwd) || process.cwd();
    let extensions = (options && options.extensions) || [".js"];

    extensions = extensions.map(ext => ext.replace(/^\./u, ""));

    let suffix = "/**";

    if (extensions.length === 1) {
        suffix += `/*.${extensions[0]}`;
    } else {
        suffix += `/*.{${extensions.join(",")}}`;
    }

    /**
     * A function that converts a directory name to a glob pattern
     *
     * @param {string} pathname The directory path to be modified
     * @returns {string} The glob path or the file path itself
     * @private
     */
    return function(pathname) {
        if (pathname === "") {
            return "";
        }

        let newPath = pathname;
        const resolvedPath = path.resolve(cwd, pathname);

        if (directoryExists(resolvedPath)) {
            newPath = pathname.replace(/[/\\]$/u, "") + suffix;
        }

        return pathUtils.convertPathToPosix(newPath);
    };
}
function processPath(options) {
    const cwd = (options && options.cwd) || process.cwd();
    let extensions = (options && options.extensions) || [".js"];

    extensions = extensions.map(ext => ext.replace(/^\./u, ""));

    let suffix = "/**";

    if (extensions.length === 1) {
        suffix += `/*.${extensions[0]}`;
    } else {
        suffix += `/*.{${extensions.join(",")}}`;
    }

    /**
     * A function that converts a directory name to a glob pattern
     *
     * @param {string} pathname The directory path to be modified
     * @returns {string} The glob path or the file path itself
     * @private
     */
    return function(pathname) {
        if (pathname === "") {
            return "";
        }

        let newPath = pathname;
        const resolvedPath = path.resolve(cwd, pathname);

        if (directoryExists(resolvedPath)) {
            newPath = pathname.replace(/[/\\]$/u, "") + suffix;
        }

        return pathUtils.convertPathToPosix(newPath);
    };
}
function processPath ( options ) { const cwd = ( options && options . cwd ) || process . cwd ( ) ; let extensions = ( options && options . extensions ) || [ ".js" ] ; extensions = extensions . map ( ext => ext . replace ( / ^\. / u , "" ) ) ; let suffix = "/**" ; if ( extensions . length === 1 ) { suffix += ` ${ extensions [ 0 ] } ` ; } else { suffix += ` ${ extensions . join ( "," ) } ` ; } /**
     * A function that converts a directory name to a glob pattern
     *
     * @param {string} pathname The directory path to be modified
     * @returns {string} The glob path or the file path itself
     * @private
     */ return function ( pathname ) { if ( pathname === "" ) { return "" ; } let newPath = pathname ; const resolvedPath = path . resolve ( cwd , pathname ) ; if ( directoryExists ( resolvedPath ) ) { newPath = pathname . replace ( / [/\\]$ / u , "" ) + suffix ; } return pathUtils . convertPathToPosix ( newPath ) ; } ; }
Checks if a provided path is a directory and returns a glob string matching
all files under that directory if so, the path itself otherwise.

Reason for this is that `glob` needs `/**` to collect all the files under a
directory where as our previous implementation without `glob` simply walked
a directory that is passed. So this is to maintain backwards compatibility.

Also makes sure all path separators are POSIX style for `glob` compatibility.

@param {Object}   [options]                    An options object
@param {string[]} [options.extensions=[".js"]] An array of accepted extensions
@param {string}   [options.cwd=process.cwd()]  The cwd to use to resolve relative pathnames
@returns {Function} A function that takes a pathname and returns a glob that
matches all files with the provided extensions if
pathname is a directory.
Checks if a provided path is a directory and returns a glob string matching all files under that directory if so the path itself otherwise .
Process a directory path to a glob pattern