1
0
mirror of https://github.com/videojs/video.js.git synced 2025-01-21 11:02:08 +02:00
video.js/build/tasks/sandbox.js
Gary Katsevman 19ebc0dda5 chore: improve dev and beginner experience (#4555)
Makes the output of dev rollup and babel watch more quiet.
Add a task to copy .example files over to non .example files if the non .example files are not present.
2017-08-14 16:58:57 -04:00

34 lines
963 B
JavaScript

const fs = require('fs');
const path = require('path');
const klawSync = require('klaw-sync');
module.exports = function(grunt) {
grunt.registerTask('sandbox', 'copy over sandbox example files if necessary', function() {
const files = klawSync('sandbox/').filter((file) => path.extname(file.path) === '.example');
const changes = files.map(function(file) {
const p = path.parse(file.path);
const nonExample = path.join(p.dir, p.name);
return {
file: file.path,
copy: nonExample
};
})
.filter(function(change) {
return !fs.existsSync(change.copy);
});
changes.forEach(function(change) {
grunt.file.copy(change.file, change.copy);
});
if (changes.length) {
grunt.log.writeln("Updated Sandbox files for:");
grunt.log.writeln('\t' + changes.map((chg) => chg.copy).join('\n\t'));
} else {
grunt.log.writeln("No sandbox updates necessary");
}
});
};