Skip to content

Commit

Permalink
removes .nodemonignore if ignoredFiles option is removed from config
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisWren committed May 3, 2013
1 parent 1104a39 commit a79f924
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tasks/nodemon.js
Expand Up @@ -14,6 +14,7 @@ module.exports = function (grunt) {
var command = [];
var options = this.options();
var done = this.async();
var nodemonignoreMessage = '# Generated by grunt-nodemon';

if (options.exec) {
command.push('--exec');
Expand All @@ -26,15 +27,18 @@ module.exports = function (grunt) {
}

if (options.ignoredFiles) {
var fileContent = '# Generated by grunt-nodemon\n';
options.ignoredFiles.forEach(function(ignoredGlob){
var fileContent = nodemonignoreMessage + '\n';
options.ignoredFiles.forEach(function (ignoredGlob) {
fileContent += ignoredGlob + '\n';
});
grunt.file.write('.nodemonignore', fileContent);
}
else if (grunt.file.exists('.nodemonignore') && grunt.file.read('.nodemonignore').indexOf(nodemonignoreMessage) === 0){
grunt.file.delete('.nodemonignore');
}

if (options.watchedFolders) {
options.watchedFolders.forEach(function(folder){
options.watchedFolders.forEach(function (folder) {
command.push('--watch');
command.push(folder);
});
Expand All @@ -43,18 +47,18 @@ module.exports = function (grunt) {
if (options.watchedExtensions) {
command.push('-e');
var extensionList = '';
options.watchedExtensions.forEach(function(extensions) {
options.watchedExtensions.forEach(function (extensions) {
extensionList += extensions + ','
});
command.push(extensionList.slice(0, -1));
}

if (options.debug) command.push('--debug');

if(options.file) command.push(options.file);
if (options.file) command.push(options.file);

if(options.args) {
options.args.forEach(function(arg){
if (options.args) {
options.args.forEach(function (arg) {
command.push(arg);
});
}
Expand All @@ -65,7 +69,8 @@ module.exports = function (grunt) {
opts: {
stdio: 'inherit'
}
}, function (error, result) {
},
function (error, result) {
if (error) {
grunt.log.error(result.stderr);
grunt.log.error('Make sure you have nodemon installed globally. You can install it by entering the following into your terminal:');
Expand Down

0 comments on commit a79f924

Please sign in to comment.