Skip to content

Instantly share code, notes, and snippets.

@kujiy
Last active November 16, 2015 02:59
Show Gist options
  • Save kujiy/c78f0679d5d407e0ed74 to your computer and use it in GitHub Desktop.
Save kujiy/c78f0679d5d407e0ed74 to your computer and use it in GitHub Desktop.
Run your shell command whenever any file is updated.
'use strict';
/**
*
* Make sure you must install modules below before use.
*
* > $ npm i grunt-contrib-watch --save-dev
* > $ npm i grunt-exec --save-dev
*
*
*/
module.exports = function(grunt) {
// Import modules from package.json's devDependencies
var taskName;
var pkg = grunt.file.readJSON('package.json');
for (taskName in pkg.devDependencies) {
if (taskName.substring(0, 6) == 'grunt-') {
grunt.loadNpmTasks(taskName);
}
}
grunt.initConfig({
watch: {
files: ['**/*'],
tasks: ['phptest'],
options: {
spawn: false,
},
},
exec: {
list_files: {
// do shell command what you want
command: 'ls -l',
stdout: true
}
}
});
grunt.registerTask('default', ['watch']);
grunt.registerTask('phptest', ['exec']);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment