Ruby Command in Grunt

Hey Everyone,

I have a Ruby Gem installed that allows me to download a Shopify theme and a Grunt workflow I use to create and deploy. Is it possible to run that Ruby command automatically through gruntfile.js?

I normally download the entire theme from the command line, “theme download”. Then I open up my Grunt workflow. I’d like to do it all in one shot each time I start Grunt so I don’t forget to download and then accidentally upload my local files, overwriting the client’s site.

(I haven’t found a grunt plugin that allows me to download a Shopify theme, only upload).

Thanks

Assuming Ruby is installed, you can always run ruby -e something.rb to execute a ruby file. Perhaps include that as a Grunt task.

Probably.

Say you have two files:

test.js

var process = require('child_process');
process.exec('ruby hello.rb',function (err,stdout,stderr) {
  if (err) {
    console.log("\n"+stderr);
  } else {
    console.log(stdout);
  }
});

hello.rb

puts "Hello"

Run:

$ node test.js
=> Hello

Play around with that and you should be able to do what you are attempting.
Docs: https://nodejs.org/api/child_process.html
Ref: http://stackoverflow.com/questions/1880198/how-to-execute-shell-command-in-javascript

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.