const formatSource = async () => { console.log(chalk.reset('Formatting source files...')); try { const sourceFilePaths = await getSourceFilePaths(); const formattedPaths = await Promise.all(sourceFilePaths.map(filePath => formatFile(filePath, filePath))); console.log(chalk.green(`Formatted ${formattedPaths.length} files.`)); } catch (error) { console.log(chalk.red('Problem formatting file:\n'), chalk.reset(error)); process.exit(1); } }
const check = async () => { console.log(chalk.reset('Validating source file formatting...')); try { const sourceFilePaths = await getSourceFilePaths(); await Promise.all( sourceFilePaths.map(async filePath => { const fileContent = await readFile(filePath); const prettierConfig = await prettier.resolveConfig(filePath); const isCompliant = prettier.check(fileContent, {...prettierConfig, filepath: filePath}); if (!isCompliant) { throw filePath; } }), ); console.log(chalk.green('Finished validating file formatting.')); } catch (error) { console.log(chalk.red('Unformatted file found:\n'), chalk.reset(error)); process.exit(1); } }
_.each(this.opt.format, function(str, index) { if (selection.cur === index) { message += chalk.reset.inverse(dateFormat(selection.date, str)); } else { message += dateFormat(selection.date, str); } });
_.each(this.opt.format, function(str) { message += chalk.reset.cyan(dateFormat(selection.date, str)); });