Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit b9ccade

Browse files
committed
chore(build): add a validation step for angularFiles
1 parent 05d3ed0 commit b9ccade

File tree

3 files changed

+55
-2
lines changed

3 files changed

+55
-2
lines changed

Gruntfile.js

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ var files = require('./angularFiles').files;
44
var util = require('./lib/grunt/utils.js');
55
var versionInfo = require('./lib/versions/version-info');
66
var path = require('path');
7+
var fs = require('fs');
78
var e2e = require('./test/e2e/tools');
9+
var glob = require("glob");
810

911
module.exports = function(grunt) {
1012
//grunt plugins
@@ -339,8 +341,58 @@ module.exports = function(grunt) {
339341
grunt.task.run('shell:npm-install');
340342
}
341343

344+
grunt.registerTask('validate-angular-files', function() {
345+
var combinedFiles = Object.assign({}, files.angularModules);
346+
combinedFiles.ng = files.angularSrc;
347+
combinedFiles.angularLoader = files.angularLoader;
348+
349+
var errorsDetected = false;
350+
var directories = [];
351+
var detectedFiles = {
352+
"src/ng/rootElement.js": true
353+
};
354+
355+
for (var section in combinedFiles) {
356+
var sectionFiles = combinedFiles[section];
357+
358+
if (section != "angularLoader") {
359+
directories.push("src/" + section);
360+
}
361+
362+
console.log("Validating " + sectionFiles.length + " files from the \"" + section + "\" module");
363+
364+
sectionFiles.forEach(function(file) {
365+
detectedFiles[file] = true;
366+
367+
if (!fs.existsSync(file)) {
368+
grunt.log.error(file + " does not exist in the local file structure");
369+
errorsDetected = true;
370+
}
371+
});
372+
}
373+
374+
directories.forEach(function(directory) {
375+
glob.sync(directory + "/**/*").forEach(function(filePath) {
376+
if (!fs.lstatSync(filePath).isDirectory()) {
377+
var fileName = path.basename(filePath);
378+
var isHiddenFile = fileName[0] == ".";
379+
if (!isHiddenFile && !detectedFiles[filePath]) {
380+
grunt.log.error(filePath + " exists in the local file structure but isn't used by any module");
381+
errorsDetected = true;
382+
}
383+
}
384+
});
385+
});
386+
387+
if (errorsDetected) {
388+
throw new Error("Not all files were properly detected the local file structure");
389+
} else {
390+
console.log("All files were detected successfully!");
391+
}
392+
});
393+
342394
//alias tasks
343-
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['jshint', 'jscs', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor']);
395+
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['validate-angular-files', 'jshint', 'jscs', 'package','test:unit','test:promises-aplus', 'tests:docs', 'test:protractor']);
344396
grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']);
345397
grunt.registerTask('test:jquery', 'Run the jQuery unit tests with Karma', ['tests:jquery']);
346398
grunt.registerTask('test:modules', 'Run the Karma module tests with Karma', ['build', 'tests:modules']);

angularFiles.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ var angularFiles = {
8585
],
8686

8787
'angularLoader': [
88-
'stringify.js',
88+
'src/stringify.js',
8989
'src/minErr.js',
9090
'src/loader.js'
9191
],

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"dgeni": "^0.4.0",
3131
"dgeni-packages": "^0.11.0",
3232
"event-stream": "~3.1.0",
33+
"glob": "^6.0.1",
3334
"grunt": "~0.4.2",
3435
"grunt-bump": "~0.0.13",
3536
"grunt-contrib-clean": "~0.6.0",

0 commit comments

Comments
 (0)