Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const isConfigured = (hintOptions: any) => {
const cloudinaryUrl = process.env.CLOUDINARY_URL; // eslint-disable-line no-process-env
const { apiKey, apiSecret, cloudName, threshold } = hintOptions;
if (threshold) {
sizeThreshold = threshold;
}
if (cloudinaryUrl) {
return true;
}
if (!apiKey || !apiSecret || !cloudName) {
logger.error(getMessage('noConfigFound', context.language));
return false;
}
cloudinary.v2.config({
api_key: apiKey,
api_secret: apiSecret,
cloud_name: cloudName
});
return true;
};
/* eslint-enable camelcase */
logger.log(`1. Run 'yarn' to install the dependencies.
2. Go to the folder 'packages/hint-${hintPackage.normalizedName}'.
3. Run 'yarn build' to build the project.
4. Go to the folder 'packages/hint'.
5. Add your hint to '.hintrc'.
6. Run 'yarn hint https://YourUrl' to analyze your site.`);
} else {
logger.log(`1. Go to the folder 'hint-${hintPackage.normalizedName}'.
2. Run 'npm run init' to install all the dependencies and build the project.
3. Run 'npm run hint -- https://YourUrl' to analyze you site.`);
}
return true;
} catch (e) {
/* istanbul ignore next */{ // eslint-disable-line no-lone-blocks
logger.error('Error trying to create new hint');
logger.error(e);
return false;
}
}
};
return total;
}
/* istanbul ignore if */
if (value[0] === '/') {
total.push(value.substr(1));
} else {
total.push(value);
}
return total;
}, []);
return result;
} catch (err) {
logger.error(getMessage('errorReading', this.engine.language));
return [];
}
}
try {
// We save the file with the friendly target name
const name = target.replace(/:\/\//g, '-')
.replace(/:/g, '-')
.replace(/\./g, '-')
.replace(/\//g, '-')
.replace(/-$/, '');
const fileName = options.output || path.resolve(cwd(), `${name}.xlsx`);
await workbook.xlsx.writeFile(fileName);
} catch (e) {
/* istanbul ignore next */
{ // eslint-disable-line
logger.error(getMessage('errorSaving', language));
if (e.message.includes('EBUSY')) {
logger.error(getMessage('maybeIsOpened', language));
}
}
}
}
}
return 1;
}
let handled = false;
notifyIfNeeded();
while (cliActions.length > 0 && !handled) {
const action = cliActions.shift()!; // Can assume not-undefined as previous line already checks the length.
/* istanbul ignore next */
try {
handled = await action(currentOptions);
} catch (e) {
logger.error(e);
return 1;
}
}
return handled ? 0 : 1;
};
export const execute = async (args: string | string[] | Object): Promise => {
let currentOptions: CLIOptions;
try {
currentOptions = options.parse(args);
} catch (e) {
logger.error(e.message);
return 1;
}
let handled = false;
notifyIfNeeded();
while (cliActions.length > 0 && !handled) {
const action = cliActions.shift()!; // Can assume not-undefined as previous line already checks the length.
/* istanbul ignore next */
try {
handled = await action(currentOptions);
} catch (e) {
logger.error(e);
return getAnalyzer(config, options, targets);
}
if (error.status === AnalyzerErrorStatus.ResourceError) {
const installed = await askToInstallPackages(error.resources!);
if (!installed) {
throw e;
}
return getAnalyzer(userConfig, options, targets);
}
if (error.status === AnalyzerErrorStatus.HintError) {
logger.error(`Invalid hint configuration in .hintrc: ${error.invalidHints!.join(', ')}.`);
throw e;
}
if (error.status === AnalyzerErrorStatus.ConnectorError) {
logger.error(`Invalid connector configuration in .hintrc`);
throw e;
}
/*
* If the error is not an AnalyzerErrorStatus
* bubble up the exception.
*/
logger.error(e.message, e);
export const validateConfig = (config: UserConfig): boolean => {
debug('Validating configuration');
const validateInfo: SchemaValidationResult = validate(schema, config);
if (!validateInfo.valid) {
logger.error('Configuration schema is not valid:');
validateInfo.groupedErrors.forEach((error: GroupedError) => {
logger.error(` - ${error.message}`);
});
return false;
}
return true;
};
.replace(/\./g, '-')
.replace(/\//g, '-')
.replace(/[?=]/g, '-query-')
.replace(/-$/, '');
const destDir = options.output || path.join(cwd(), 'hint-report');
const destination = path.join(destDir, `${name}.html`);
await fs.outputFile(destination, html);
logger.log(getMessageFormatter('youCanView', language, destination));
}
return result;
} catch (err) {
logger.error(err);
throw err;
}
}
}
validateInfo.groupedErrors.forEach((error: GroupedError) => {
logger.error(` - ${error.message}`);
});