Created
May 1, 2015 17:49
-
-
Save JMBattista/4860c46e84a3e8ced846 to your computer and use it in GitHub Desktop.
Use forever to run a grunt command
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
module.exports = function (grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
watch: { | |
scripts: { | |
files: ['<The file(s) to watch'], | |
tasks: ['<The task to run>'], | |
options: { | |
spawn: false | |
} | |
} | |
}, | |
forever: { | |
watch: { | |
options: { | |
index: 'gruntstart.js', | |
logFile: 'watch.logs', | |
outFile: 'watch.logs', | |
errFile: 'watch.logs' | |
} | |
} | |
} | |
}); | |
// Load modules | |
grunt.loadNpmTasks('grunt-forever'); | |
grunt.loadNpmTasks('grunt-contrib-watch'); | |
// Register tasks | |
grunt.registerTask('default', ['forever:watch:restart']); | |
}; |
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
/** | |
* Credit to Антон Брагин | |
* from http://stackoverflow.com/questions/15622116/grunt-js-watch-forever | |
* For providing this piece of code | |
*/ | |
var exec = require('child_process').exec; | |
exec('grunt watch > log/grunt.log', | |
function (error, stdout, stderr) { | |
console.log('stdout: ' + stdout); | |
console.log('stderr: ' + stderr); | |
if (error !== null) { | |
console.log('exec error: ' + error); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment