Matthew
Matthew

Reputation: 621

Use gulp.js for Shopify theme deployment via Shopify CLI and to GitHub

I'm using the Shopify CLI for local theme development, and Gulp for automation. This is my first experience with both, so it's a bit of a learning experience.

I'd like to use Gulp to handle the shopify theme push command, but haven't been able to make it work yet.

The end goal, if possible, is to set up a single Gulp task that will git commit (prompting for the commit message), then push to my GitHub repository, then push to my Shopify store.

Is this beyond the scope of Gulp? It seems there ought to be a way to do this, but as I said, I'm just starting to figure out what it can do.

Upvotes: 0

Views: 589

Answers (1)

davidthorand
davidthorand

Reputation: 403

You could spawn a node child process to run the shopify theme push command:

const { spawn } = require('child_process');

const child = spawn('shopify', ['theme', 'push']);

child.stdout.on('data', data => {
  console.log('stdout:\n');
  console.log(data);
});

child.stderr.on('data', data => {
  console.log('stderr:\n');
  console.log(data);
});

Chaining the steps should definitely be in the scope of gulp.

Upvotes: 0

Related Questions