How to use the @hint/utils-fs.isDirectory function in @hint/utils-fs

To help you get started, we’ve selected a few @hint/utils-fs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github webhintio / hint / packages / utils-network / src / as-uri.ts View on Github external
/* istanbul ignore else */
    /*
     * If it's a URI.
     * Check if the protocol is HTTP or HTTPS.
     */
    if (protocol === 'http:' || protocol === 'https:' || protocol === 'file:') {
        debug(`Adding valid target: ${target && url.format(target)}`);

        return target;
    }

    /*
     * If it's not a URI
     * If it does exist and it's a regular file.
     */
    if (isFile(source) || isDirectory(source)) {
        target = new URL(fileUrl(source));
        debug(`Adding valid target: ${url.format(target)}`);

        return target;
    }

    target = new URL(`http://${source}`);

    /*
     * And it doesn't exist locally, and is a valid URL:
     * Except for the case of the well known and used `localhost`,
     * for all other cases the `hostname` needs to contain at least
     * a `.`. Private domains should have `http(s)://` in front.
     */
    if (!pathExists(source) && (target.hostname === 'localhost' || target.hostname.includes('.'))) {
        debug(`Adding modified target: ${url.format(target)}`);
github webhintio / hint / packages / utils / src / chromium-finder.ts View on Github external
const findChromeExecutable = (folder: string, regExes: string[]) => {
    const argumentsRegex = /(^[^ ]+).*/; // Take everything up to the first space

    for (const browserRegex of regExes) {

        const chromeExecRegex = `^Exec=/.*/${browserRegex}-.*`;

        if (isDirectory(folder)) {
            /*
             * Output of the grep & print looks like:
             *    /opt/google/chrome/google-chrome --profile-directory
             *    /home/user/Downloads/chrome-linux/chrome-wrapper %U
             */
            let execPaths;

            /*
             * Some systems do not support grep -R so fallback to -r.
             * See https://github.com/GoogleChrome/chrome-launcher/issues/46 for more context.
             */
            try {
                execPaths = execSync(`grep -ER "${chromeExecRegex}" ${folder} | awk -F '=' '{print $2}'`);
            } catch (e) {
                execPaths = execSync(`grep -Er "${chromeExecRegex}" ${folder} | awk -F '=' '{print $2}'`);
            }