Skip to content

Commit

Permalink
chore: Ensure generated files exist (#1133)
Browse files Browse the repository at this point in the history
This PR introduces a new task which ensures, existence of a given set of files. In this case it checks, for `axe.***.js` files for all langs specified. If the build generated files do not exist, a fatal error is thrown. Also, the same files are checked for existence as a part of `prepublishOnly` step.


<img width="504" alt="screen shot 2018-09-12 at 08 54 26" src="https://user-images.githubusercontent.com/20978252/45410410-85f44680-b669-11e8-9649-8d02dc4bb3df.png">


Closes issue:
- #1117

## Reviewer checks

**Required fields, to be filled out by PR reviewer(s)**
- [x] Follows the commit message policy, appropriate for next version
- [x] Has documentation updated, a DU ticket, or requires no documentation change
- [x] Includes new tests, or was unnecessary
- [x] Code is reviewed for security by: @WilcoFiers
  • Loading branch information
jeeyyy authored and WilcoFiers committed Sep 26, 2018
1 parent 031f798 commit ae2e093
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions circle.yml → .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ version: 2

defaults: &defaults
docker:
- image: circleci/node:6.12.3-browsers
- image: circleci/node:10-browsers-legacy
working_directory: ~/axe-core

restore_dependency_cache: &restore_dependency_cache
Expand Down Expand Up @@ -93,4 +93,4 @@ workflows:
- hold
filters:
branches:
only: master
only: master
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@ package-lock.json
!lib/core/imports/index.js
lib/core/imports/*.js

# running circleci locally to verify build, ignoring relevant files
# if circle and docker is configured locally (copy circle.yml to .circleci/config.yml) - run -> circleci build
.circleci/**/*.*

# ignore jsdoc api documentation generated files
doc/api/*
doc/api/*
8 changes: 8 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ module.exports = function(grunt) {
}
}
},
'file-exists': {
data: langs.reduce(function(out, lang) {
out.push('axe' + lang + '.js');
out.push('axe' + lang + '.min.js');
return out;
}, [])
},
watch: {
files: ['lib/**/*', 'test/**/*.js', 'Gruntfile.js'],
tasks: ['build', 'testconfig', 'fixture']
Expand Down Expand Up @@ -391,6 +398,7 @@ module.exports = function(grunt) {

grunt.registerTask('test', [
'build',
'file-exists',
'retire',
'testconfig',
'fixture',
Expand Down
21 changes: 21 additions & 0 deletions build/tasks/file-exists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

module.exports = function(grunt) {
grunt.registerMultiTask(
'file-exists',
'Task to ensure existence of generated build assets',
function() {
this.data.forEach(function(f) {
var files = grunt.file.expand({ nonull: true }, f);
files.forEach(function(filepath) {
var exists = grunt.file.exists(filepath);
if (!!exists) {
grunt.log.writeln('File: ' + filepath + ', exists.');
} else {
grunt.fail.fatal('File: ' + filepath + ', does not exist.');
}
});
});
}
);
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"test": "npm run test-dts && grunt test",
"test-fast": "grunt test-fast",
"version": "echo \"use 'npm run release' to bump axe-core version\" && exit 1",
"prepublishOnly": "grunt build",
"prepublishOnly": "grunt build && grunt file-exists",
"postinstall": "node build/utils/postinstall.js",
"release": "standard-version -a",
"next-release": "standard-version --scripts.prebump=./build/next-version.js --skip.commit=true --skip.tag=true",
Expand Down

0 comments on commit ae2e093

Please sign in to comment.