Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const askToInstallPackages = async (resources: HintResources): Promise => {
if (resources.missing.length > 0) {
appInsights.trackEvent('cli-missing', resources.missing);
}
if (resources.incompatible.length > 0) {
appInsights.trackEvent('cli-incompatible', resources.incompatible);
}
const missingPackages = resources.missing.map((name) => {
return `@hint/${name}`;
});
const incompatiblePackages = resources.incompatible.map((name) => {
// If the packages are incompatible, we need to force to install the latest version.
return `@hint/${name}@latest`;
});
if (!(await askUserToInstallDependencies(resources) &&
await installPackages(missingPackages) &&
await installPackages(incompatiblePackages))) {
// The user doesn't want to install the dependencies or something went wrong installing them
const alreadyRun: boolean = configStore.get(alreadyRunKey);
if (!alreadyRun) {
configStore.set(alreadyRunKey, true);
}
if (!telemetryConfigured) {
if (isCI) {
showCITelemetryMessage();
telemetryEnabled = false;
} else if (alreadyRun) {
/* Only prompt the user about opt-intelemetry if they have run webhint before. */
telemetryEnabled = await askForTelemetryConfirmation();
if (telemetryEnabled) {
appInsights.trackEvent('cli-telemetry');
}
}
}
if (!telemetryEnabled) {
return;
}
appInsights.trackEvent('cli-analyze', {
ci: isCI,
previouslyRun: alreadyRun,
...pruneUserConfig(userConfig)
});
};
const askToInstallPackages = async (resources: HintResources): Promise => {
if (resources.missing.length > 0) {
appInsights.trackEvent('cli-missing', resources.missing);
}
if (resources.incompatible.length > 0) {
appInsights.trackEvent('cli-incompatible', resources.incompatible);
}
const missingPackages = resources.missing.map((name) => {
return `@hint/${name}`;
});
const incompatiblePackages = resources.incompatible.map((name) => {
// If the packages are incompatible, we need to force to install the latest version.
return `@hint/${name}@latest`;
});
if (!(await askUserToInstallDependencies(resources) &&
telemetryEnabled = false;
} else if (alreadyRun) {
/* Only prompt the user about opt-intelemetry if they have run webhint before. */
telemetryEnabled = await askForTelemetryConfirmation();
if (telemetryEnabled) {
appInsights.trackEvent('cli-telemetry');
}
}
}
if (!telemetryEnabled) {
return;
}
appInsights.trackEvent('cli-analyze', {
ci: isCI,
previouslyRun: alreadyRun,
...pruneUserConfig(userConfig)
});
};