Skip to content

Commit

Permalink
chore: fix prettier format for built files (#4258)
Browse files Browse the repository at this point in the history
* chore: fix prettier format for built files

* catch
  • Loading branch information
straker committed Nov 28, 2023
1 parent f7b8d5e commit f1af598
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 15 deletions.
15 changes: 11 additions & 4 deletions build/tasks/aria-supported.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module.exports = function (grunt) {
* as `axe` does not exist until grunt task `build:uglify` is complete,
* hence cannot be required at the top of the file.
*/
const done = this.async();
const { langs } = this.options();
const fileNameSuffix = langs && langs.length > 0 ? `${langs[0]}` : '';
const axe = require(`../../axe${fileNameSuffix}`);
Expand Down Expand Up @@ -69,10 +70,16 @@ module.exports = function (grunt) {
const destFile = this.data.destFile;
// Format the content so Prettier doesn't create a diff after running.
// See https://github.com/dequelabs/axe-core/issues/1310.
const formattedContent = format(content, destFile);

// write `aria supported` file contents
grunt.file.write(destFile, formattedContent);
format(content, destFile)
.then(formattedContent => {
// write `aria supported` file contents
grunt.file.write(destFile, formattedContent);
done();
})
.catch(err => {
console.error(err.message);
done(false);
});

/**
* Get list of aria attributes, from `aria-query`
Expand Down
25 changes: 14 additions & 11 deletions build/tasks/configure.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*eslint-env node */
'use strict';
var buildRules = require('../configure');
var format = require('../shared/format');
const buildRules = require('../configure');
const format = require('../shared/format');

module.exports = function (grunt) {
grunt.registerMultiTask(
'configure',
'Task for configuring rules and checks',
function () {
var done = this.async();
var options = this.options({
const done = this.async();
const options = this.options({
rules: ['lib/rules/**/*.json'],
checks: ['lib/checks/**/*.json'],
misc: ['lib/misc/**/*.json'],
Expand All @@ -18,7 +18,7 @@ module.exports = function (grunt) {
});

this.files.forEach(function (file) {
var match = file.dest.auto.match(/\.([a-z]{2,3})\.js/);
const match = file.dest.auto.match(/\.([a-z]{2,3})\.js/);
if (match) {
options.locale = match[1];
}
Expand All @@ -28,12 +28,15 @@ module.exports = function (grunt) {

// Format the content so Prettier doesn't create a diff after running.
// See https://github.com/dequelabs/axe-core/issues/1310.
const descriptionsContent = format(
result.descriptions,
file.dest.descriptions
);
grunt.file.write(file.dest.descriptions, descriptionsContent);
done();
format(result.descriptions, file.dest.descriptions)
.then(descriptionsContent => {
grunt.file.write(file.dest.descriptions, descriptionsContent);
done();
})
.catch(err => {
console.error(err.message);
done(false);
});
});
});
}
Expand Down

0 comments on commit f1af598

Please sign in to comment.