2015-12-28 22:53:39 +01:00
|
|
|
import { isAdded, getFilename } from './utils/files_to_commit';
|
|
|
|
|
|
|
|
export default function registerCheckAddedFilenames(grunt) {
|
|
|
|
grunt.registerTask('checkAddedFilenames', function () {
|
|
|
|
grunt.task.requires('collectFilesToCommit');
|
|
|
|
|
|
|
|
const invalid = grunt.config
|
|
|
|
.get('filesToCommit')
|
|
|
|
.map(getFilename)
|
2016-03-12 00:42:19 +01:00
|
|
|
.filter(isAdded)
|
|
|
|
.filter(name => !name.match(/([\/\\]|^)(docs|tasks[\/\\]config|webpackShims)([\/\\]|$)/))
|
2015-12-28 22:53:39 +01:00
|
|
|
.filter(name => name.match(/[A-Z \-]/))
|
|
|
|
.reduce((all, name) => `${all} ${name}\n`, '');
|
|
|
|
|
|
|
|
if (invalid) {
|
|
|
|
grunt.fail.fatal(`Filenames must use snake_case.\n${invalid}`);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|