Reputation: 13270
The title may be contradictory but let say i have a software (s1) WYSIWYG but this software is not really WYSIWYW (what you see is what you write), when editing the source file and saving, the software is not updating the result frame.
However if another software (s2) is touching the file, s1's result frame is updated and now what you see is what you get (some kind of trick ye..).
I am using grunt-contrib-watch
to watch a certain set of files, let say it is s2 in my scenario. When I edit a being-watched file in s1, i want the watcher to execute a task that touches this file as well so s1 is showing the result.
this is basically the code i want :
module.exports = function (grunt) {
grunt.initConfig({
touch: {
src: "the being-saved '.cf' file" // how can I reference this file ?
},
watch: {
files: ['**/*.cf'],
tasks: ['touch']
}
});
grunt.loadNpmTasks('grunt-touch');
grunt.loadNpmTasks('grunt-contrib-watch');
};
when i edit and save a .cf
file I want the watcher to execute the touch task touching the .cf
file that has just been saved.
How can I do that ?
Upvotes: 0
Views: 252
Reputation: 1129
Have you tried touching the file on watch event? Use this approach to perform grunt tasks selectively on files.
You can play around with this kind of setup:
grunt.event.on('watch', function(action, filepath) {
//filepath is what you need
//do the touch here. ie: set the src of touch task
grunt.config('touch.src', filepath);
//do some more work if needed
//...
//tell watch what to do
grunt.config('watch.tasks', 'touch');
});
You might have to add nospawn to watch task to have it run in the same context:
options : { nospawn : true }
Hope this helps!
Upvotes: 1