How to use the @hint/utils.findPackageRoot function in @hint/utils

To help you get started, we’ve selected a few @hint/utils 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 / create-hint / src / utils.ts View on Github external
export const loadCreateHintPackage = () => {
    // webpack will embed the package.json
    /* istanbul ignore if */
    if (process.env.webpack) { // eslint-disable-line no-process-env
        return require('../package.json');
    }

    const pkgRoot = findPackageRoot(__dirname, 'package.json');

    return require(`${pkgRoot}/package.json`);
};
github webhintio / hint / packages / hint / src / lib / utils / resource-loader.ts View on Github external
hasMultipleResources,
    isFullPackageName,
    loadResource,
    requirePackage,
    ResourceErrorStatus,
    ResourceType
} from '@hint/utils';
import { readFile } from '@hint/utils-fs';
import { debug as d } from '@hint/utils-debug';

import { IHintConstructor, HintResources } from '../types';
import { Configuration } from '../config';
import { IConnectorConstructor } from '../types/connector';

const debug: debug.IDebugger = d(__filename);
const HINT_ROOT: string = findPackageRoot();
const NODE_MODULES_ROOT: string = (() => {
    const root: string = findNodeModulesRoot();

    return root;
})();

/** Cache of resources ids. */
const resourceIds: Map = new Map();

/*
 * ------------------------------------------------------------------------------
 * Public
 * ------------------------------------------------------------------------------
 */

/** Returns a list with the ids of all the core resources of the given `type`. */
github webhintio / hint / packages / hint-typescript-config / src / target.ts View on Github external
const browserslistConfigExists = (): boolean => {
            let browserslistFolder: string | null;

            try {
                browserslistFolder = findPackageRoot(__dirname, '.browserslistrc');
            } catch (e) {
                browserslistFolder = null;
            }

            if (browserslistFolder) {
                return true;
            }

            let packageJsonFolder: string | null;

            try {
                packageJsonFolder = findPackageRoot(__dirname, 'package.json');
            } catch (e) {
                packageJsonFolder = null;
            }
github webhintio / hint / packages / hint-typescript-config / src / target.ts View on Github external
let browserslistFolder: string | null;

            try {
                browserslistFolder = findPackageRoot(__dirname, '.browserslistrc');
            } catch (e) {
                browserslistFolder = null;
            }

            if (browserslistFolder) {
                return true;
            }

            let packageJsonFolder: string | null;

            try {
                packageJsonFolder = findPackageRoot(__dirname, 'package.json');
            } catch (e) {
                packageJsonFolder = null;
            }

            if (packageJsonFolder) {
                const packageJson = require(path.join(packageJsonFolder, 'package.json'));

                return !!packageJson.browserslist;
            }

            return false;
        };