I have a collection of .svg files. When I modify one of them, I would like grunt to re-run a command on each svg file that was modified
inkscape --file=FILENAME.svg --export-pdf=FILENAME.pdf
So far, I have this grunt script
module.exports = function (grunt) {
'use strict';
grunt.initConfig({
shell: {
figures: {
command: 'inkscape --file=FILENAME.svg --export-pdf=FILENAME.pdf'
}
},
watch: {
figs: {
files: '**/*.svg',
tasks: ['shell:figures']
}
}
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');
grunt.registerTask('default', [watch']);
};
But I have no idea how to configure grunt in order to replace FILENAME by the name of each file that was modified.
I solved the issue using a config variable that is modified on the
watchevent beforeshell:figsrunsThe only downside is that
shell:figscannot be called manually, it only works when running thewatchtask, or simplygrunt.