Skip to content

Commit

Permalink
Merge pull request #404 from LibanHassan/patch-1
Browse files Browse the repository at this point in the history
Altered handleFileEvent to be able to accept extensions other than .ts and .html
  • Loading branch information
nycdotnet authored May 29, 2017
2 parents f9afde9 + aaf3247 commit 95be19f
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions tasks/ts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,23 +431,28 @@ const pluginFn = function (grunt: IGrunt) {
// local event to handle file event
function handleFileEvent(filepath: string, displaystr: string, addedOrChanged: boolean = false) {

// Only ts and html :
if (!utils.endsWith(filepath.toLowerCase(), '.ts') && !utils.endsWith(filepath.toLowerCase(), '.html')) {
return;
}
const acceptedExtentions = ['.ts', '.tsx', '.js', '.jsx', '.html'];

// Do not run if just ran, behaviour same as grunt-watch
// These are the files our run modified
if ((new Date().getTime() - lastCompile) <= 100) {
// Uncomment for debugging which files were ignored
// grunt.log.writeln((' ///' + ' >>' + filepath).grey);
return;
}
acceptedExtentions.forEach(
(extension) => {

// If extension is accepted and was not just run
if (utils.endsWith(filepath.toLowerCase(), extension) && (new Date().getTime() - lastCompile) > 100){

// Log and run the debounced version.
grunt.log.writeln((displaystr + ' >>' + filepath).yellow);

// Log and run the debounced version.
grunt.log.writeln((displaystr + ' >>' + filepath).yellow);
filterFilesTransformAndCompile();

filterFilesTransformAndCompile();
return;
}

// Uncomment for debugging which files were ignored
// else if ((new Date().getTime() - lastCompile) <= 100){
// grunt.log.writeln((' ///' + ' >>' + filepath).grey);
// }
}
);
}

}).then((res: boolean[]) => {
Expand Down

0 comments on commit 95be19f

Please sign in to comment.