This repository was archived by the owner on Apr 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 27.4k
chore(GruntFile): check angularFiles (update) #13569
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a998d98
chore(build): add a validation step for angularFiles
matsko 08ff720
chore(npm-shrinkwrap): install glob package
petebacondarwin a8b5f5c
chore(angularFiles): add documentation only file to list of files
petebacondarwin fc2650b
chore(GruntFile): move `validate-angular-files` task into its own file
petebacondarwin 108e8a6
chore(GruntFile): fix whitespace in lists
petebacondarwin bc6cd06
chore(GruntFile): move `validate-angular-files` task into its own file
petebacondarwin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use strict'; | ||
|
||
var path = require('path'); | ||
var fs = require('fs'); | ||
var glob = require("glob"); | ||
var _ = require('lodash'); | ||
var files = require('../../angularFiles').files; | ||
|
||
module.exports = function(grunt) { | ||
|
||
grunt.registerTask('validate-angular-files', function() { | ||
var combinedFiles = _.clone(files.angularModules); | ||
combinedFiles.ng = files.angularSrc; | ||
combinedFiles.angularLoader = files.angularLoader; | ||
|
||
var errorsDetected = false; | ||
var directories = []; | ||
var detectedFiles = {}; | ||
|
||
for (var section in combinedFiles) { | ||
var sectionFiles = combinedFiles[section]; | ||
|
||
if (section != "angularLoader") { | ||
directories.push("src/" + section); | ||
} | ||
|
||
grunt.log.debug("Validating " + sectionFiles.length + " files from the \"" + section + "\" module."); | ||
|
||
sectionFiles.forEach(function(file) { | ||
detectedFiles[file] = true; | ||
|
||
if (!fs.existsSync(file)) { | ||
grunt.log.error(file + " does not exist in the local file structure."); | ||
errorsDetected = true; | ||
} | ||
}); | ||
} | ||
|
||
directories.forEach(function(directory) { | ||
glob.sync(directory + "/**/*").forEach(function(filePath) { | ||
if (!fs.lstatSync(filePath).isDirectory()) { | ||
var fileName = path.basename(filePath); | ||
var isHiddenFile = fileName[0] == "."; | ||
if (!isHiddenFile && !detectedFiles[filePath]) { | ||
grunt.log.error(filePath + " exists in the local file structure but isn't used by any module."); | ||
errorsDetected = true; | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
if (errorsDetected) { | ||
throw new Error("Not all files were properly detected in the local file structure."); | ||
} else { | ||
grunt.log.ok("All files were detected successfully!"); | ||
} | ||
}); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error message is not 100% accurate (as the errors might be due to files in the local file structure not being used).