Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
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}"`;
});
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
});
};
export default (): Promise => {
const pkg = loadHintPackage();
logger.log(`v${pkg.version}`);
return Promise.resolve(true);
};