How to use the @hint/utils.loadHintPackage 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 / hint / src / lib / cli.ts View on Github external
const notifyIfNeeded = () => {
    const pkg = loadHintPackage();
    /*
     * Fetch and persist comparison result in the background.
     * Check interval is set as one day by default.
     * To test immediately, set `updateCheckInterval` to 0 and pass it in as a param to `updateNotifier`.
     * Comparison result is loaded on the FIRST initiation, but users won't be notified until the SECOND time it runs.
     * Reference:https://github.com/yeoman/update-notifier#how
     */
    const notifier = updateNotifier({
        pkg,
        updateCheckInterval: 1000 * 60 * 60 * 1 // One hour.
    });

    const update = notifier.update;

    if (!update || update.latest === pkg.version) {
        return;
github webhintio / hint / packages / create-parser / src / handlebars-utils.ts View on Github external
import * as Handlebars from 'handlebars';

import { readFileAsync } from '@hint/utils-fs';
import { loadHintPackage } from '@hint/utils';

const pkg = loadHintPackage();

/**
 * Searches the current version used for a package in `hint` and uses that version or the `defaultVersion`.
 *
 * This is used when creating a new hint via the CLI to make sure the dependencies are up-to-date in the moment
 * of creation.
 */
Handlebars.registerHelper('dependencyVersion', (packageName, defaultVersion): string => {
    const version = packageName === 'hint' ?
        `^${pkg.version}` :
        pkg.dependencies[packageName] ||
        pkg.devDependencies[packageName] ||
        defaultVersion;

    return `"${packageName}": "${version}"`;
});
github webhintio / hint / packages / hint / src / lib / cli / analyze.ts View on Github external
const print = async (reports: Problem[], target?: string, scanTime?: number, date?: string): Promise => {
        await webhint.format(reports, {
            config: userConfig || undefined,
            date,
            output: actions.output ? path.resolve(cwd(), actions.output) : undefined,
            resources: webhint.resources,
            scanTime,
            target,
            version: loadHintPackage().version
        });
    };
github webhintio / hint / packages / hint / src / lib / cli / version.ts View on Github external
export default (): Promise => {

    const pkg = loadHintPackage();

    logger.log(`v${pkg.version}`);

    return Promise.resolve(true);
};