Skip to content

Commit

Permalink
start on building with all langs
Browse files Browse the repository at this point in the history
  • Loading branch information
WilcoFiers committed Mar 9, 2017
1 parent 5c75606 commit 9cce3da
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 36 deletions.
85 changes: 52 additions & 33 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,15 @@ module.exports = function (grunt) {
grunt.loadTasks('build/tasks');
grunt.loadNpmTasks('grunt-parallel');

var lang = '';
if (grunt.option('lang')) {
lang = '.' + grunt.option('lang');
var langs;
if (grunt.option('all-lang')) {
langs = ['.nl', '.en', '.de'];

} else if (grunt.option('lang')) {
langs = ['.' + grunt.option('lang')];

} else {
langs = [''];
}

grunt.initConfig({
Expand All @@ -39,14 +45,14 @@ module.exports = function (grunt) {
]
}
},
retire: {
retire: {
options: {
/** list of files to ignore **/
ignorefile: '.retireignore.json' //or '.retireignore.json'
},
js: ['lib/*.js'], /** Which js-files to scan. **/
node: ['./'] /** Which node directories to scan (containing package.json). **/
},
},
clean: ['dist', 'tmp'],
babel: {
options: {
Expand Down Expand Up @@ -79,20 +85,24 @@ module.exports = function (grunt) {
},
concat: {
engine: {
src: [
'lib/intro.stub',
'tmp/core/index.js',
'tmp/core/*/index.js',
'tmp/core/**/index.js',
'tmp/core/**/*.js',
// include rules / checks / commons
'<%= configure.rules.dest.auto %>',
'lib/outro.stub'
],
dest: 'axe' + lang + '.js',
options: {
process: true
}
},
files: langs.map(function (lang, i) {
return {
src: [
'lib/intro.stub',
'tmp/core/index.js',
'tmp/core/*/index.js',
'tmp/core/**/index.js',
'tmp/core/**/*.js',
// include rules / checks / commons
'<%= configure.rules.files[' + i + '].dest.auto %>',
'lib/outro.stub'
],
dest: 'axe' + lang + '.js',
};
})
},
commons: {
src: [
Expand All @@ -107,14 +117,19 @@ module.exports = function (grunt) {
},
configure: {
rules: {
src: ['<%= concat.commons.dest %>'],
tmp: 'tmp/rules.js',
options: {
tags: grunt.option('tags')
},
dest: {
auto: 'tmp/rules.js',
descriptions: 'doc/rule-descriptions.md'
}
files: langs.map(function (lang) {
return {
src: ['<%= concat.commons.dest %>'],
dest: {
auto: 'tmp/rules' + lang + '.js',
descriptions: 'doc/rule-descriptions' + lang + '.md'
}
};
})
}
},
langs : {
Expand Down Expand Up @@ -144,10 +159,12 @@ module.exports = function (grunt) {
},
uglify: {
beautify: {
files: [{
src: ['<%= concat.engine.dest %>'],
dest: '<%= concat.engine.dest %>'
}],
files: langs.map(function (lang, i) {
return {
src: ['<%= concat.engine.files[' + i + '].dest %>'],
dest: '<%= concat.engine.files[' + i + '].dest %>'
};
}),
options: {
mangle: false,
compress: false,
Expand All @@ -161,10 +178,12 @@ module.exports = function (grunt) {
}
},
minify: {
files: [{
src: ['<%= concat.engine.dest %>'],
dest: './axe' + lang + '.min.js'
}],
files: langs.map(function (lang, i) {
return {
src: ['<%= concat.engine.files[' + i + '].dest %>'],
dest: './axe' + lang + '.min.js'
};
}),
options: {
preserveComments: function(node, comment) {
// preserve comments that start with a bang
Expand Down Expand Up @@ -202,7 +221,7 @@ module.exports = function (grunt) {
src: [
'<%= concat.engine.dest %>',
'build/test/engine.js',
'<%= configure.rules.dest.auto %>'
'<%= configure.rules.tmp %>'
],
dest: 'test/checks/index.html',
options: {
Expand All @@ -217,7 +236,7 @@ module.exports = function (grunt) {
src: [
'<%= concat.engine.dest %>',
'build/test/engine.js',
'<%= configure.rules.dest.auto %>'
'<%= configure.rules.tmp %>'
],
dest: 'test/commons/index.html',
options: {
Expand All @@ -232,7 +251,7 @@ module.exports = function (grunt) {
src: [
'<%= concat.engine.dest %>',
'build/test/engine.js',
'<%= configure.rules.dest.auto %>'
'<%= configure.rules.tmp %>'
],
dest: 'test/rule-matches/index.html',
options: {
Expand Down
7 changes: 4 additions & 3 deletions build/tasks/configure.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ module.exports = function (grunt) {
blacklist: ['metadata'],
tags: ''
});
var that = this;

this.files.forEach(function (file) {
var commons = file.src[0];

buildRules(grunt, options, commons, function (result) {
grunt.file.write(that.data.dest.auto, 'axe._load(' + result.auto + ');');
grunt.file.write(that.data.dest.descriptions, result.descriptions);
grunt.file.write(file.dest.auto, 'axe._load(' + result.auto + ');');
grunt.file.write(file.dest.descriptions, result.descriptions);
done();
});
});
Expand Down

0 comments on commit 9cce3da

Please sign in to comment.