Skip to content
Snippets Groups Projects

Task update2024

Merged Johannes Kreiner requested to merge task_update2024 into master
Compare and Show latest version
6 files
+ 118
55
Compare changes
  • Side-by-side
  • Inline
Files
6
+ 9
5
@@ -162,13 +162,14 @@ export default class Lint extends Task {
* Kicks of the prettier task
*/
async runPrettier(files) {
let configFile = await prettier.resolveConfigFile('./');
let configFile = await prettier.resolveConfigFile(process.cwd());
if (!configFile) {
// Fallback configuration from sgc-core
configFile = await prettier.resolveConfigFile('./sgc-core/');
configFile = await prettier.resolveConfigFile(path.join(process.cwd(), 'sgc-core'));
}
const config = await prettier.resolveConfig(configFile);
const config = await prettier.resolveConfig(configFile);
const calls = [];
files.forEach((file) => {
calls.push(this.prettify(file, { ...config, filepath: file }));
@@ -185,7 +186,7 @@ export default class Lint extends Task {
* @returns {Promise<void>}
*/
async prettify(file, config) {
const content = await fs.readFile(file, 'utf-8');
const content = await fs.readFile(file, 'utf8');
// Check if file is already formatted
if (await prettier.check(content, config)) {
@@ -193,7 +194,10 @@ export default class Lint extends Task {
}
this._logger.info(`Running prettier on file ${file}`);
const formatted = await prettier.format(content, config);
const formatted = await prettier.format(content, {
...config,
...(file.includes('.scss') ? { trailingComma: 'none' } : {})
});
await fs.writeFile(file, formatted);
}
}
Loading