How to get grunt task output feed to another grunt task?

I'm not sure if grunts can do this. I have two grunt tasks that I want to run. The first task is to create a post layout, and the second is to launch the penthouse task for inline css. Any hacking welcome.

This is the exec task that I have to run in order to create a WordPress blog post.

  exec: { create_mock: { cmd: 'cd ~/MyProjects/project/vip-quickstart && vagrant ssh -c \'sh /srv/www/wp-content/themes/vip/the-theme/bin/mock-post.sh\'', callback: function(err, stdout, stderr) { grunt.log.write('stdout: ' + stdout); // This is the url of the created post. } } }, 

The output is the URL that was created in the blog post, and I have this penthouse task to run, which I need to pass in the url so that this task looks in order to get all of the above css.

  penthouse: { singular: { outfile: 'assets/css/inline/_singular.css', css: 'assets/css/theme.css', minify: true, url: $URL, // << I want to feed in the url from the previous task to here. width: 1300, height: 900 } }, 

The hacky way I can think of is to save the file to a file and read it in the penthouse task, but I think there should be a better way to do this.

Thank you very much.

+5
source share
1 answer

You can use grunt.config.set to set the value directly (or to another property and using it with grunt.template if you need to use the value several times.)

  exec: { create_mock: { cmd: 'cd ~/MyProjects/project/vip-quickstart && vagrant ssh -c \'sh /srv/www/wp-content/themes/vip/the-theme/bin/mock-post.sh\'', callback: function(err, stdout, stderr) { grunt.config.set("penthouse.singular.url", stdout); } } }, 
+3
source

All Articles