Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const loadConfiguration = (configurationId: string, configurations?: string[]) => {
return loadResource(configurationId, ResourceType.configuration, configurations);
};
const extendConfig = async (): Promise => {
const configPackages: NpmPackage[] = await getOfficialPackages(ResourceType.configuration);
if (!anyResources(configPackages, ResourceType.configuration)) {
return null;
}
const configNames = configPackages.map((pkg) => {
return {
name: getConfigurationName(pkg.name),
value: pkg.name
};
});
const choices = configNames.filter((config) => {
return config.name !== 'all';
});
const extendConfig = async (): Promise => {
const configPackages: NpmPackage[] = await getOfficialPackages(ResourceType.configuration);
if (!anyResources(configPackages, ResourceType.configuration)) {
return null;
}
const configNames = configPackages.map((pkg) => {
return {
name: getConfigurationName(pkg.name),
value: pkg.name
};
});
const choices = configNames.filter((config) => {
return config.name !== 'all';
});
const questions: inquirer.Questions = [{
choices,
const initialAnswer: inquirer.Answers = await inquirer.prompt(initialQuestion);
const result = initialAnswer.configType === 'predefined' ?
await extendConfig() :
await customConfig();
if (!result) {
return false;
}
const filePath: string = path.join(cwd(), '.hintrc');
await promisify(fs.writeFile)(filePath, JSON.stringify(result.config, null, 4), 'utf8');
if (Array.isArray(result.packages) && result.packages.length > 0) {
const isInstalled = getInstalledResources(ResourceType.configuration).includes(getConfigurationName(result.packages[0]));
if (isInstalled) {
return true;
}
await installPackages(result.packages);
}
trackEvent('new-hintrc', result.config);
await sendPendingData();
return true;
};