folks,
Trying to automate some repeated tasks when switching projects and hit a weird edge-case snag.
When I use the shopify-cli tool to log in to a store, shopify login --store=storename, my terminal (on mac os) opens my browser to authenticate with shopify. shopify-cli will sit there indefinitely waiting for me to verify my identity in my browser, you get a big "Successfully authenticated. You may now close your browser." message in your browser window, and the shell tool finishes running, outputting: 'Logged into store storename.myshopify.com".
Problem is, when I put the same command in gulp:
gulp.task('login', function(cli) {
var cmd = spawn('shopify', ['login', '--store=storename'], {});
cmd.on('close', function (code, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cli(err);
})
});
or like so:
gulp.task('login', function(cli) {
exec('shopify login --store=storename', function(err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cli(err);
})
});
Gulp doesn't push through the browser open/authenticate process to stdout. So login just hangs there not doing anything useful, waiting for the browser that never opened to tell it I've authenticated successfully. I suspect this is related to using console.log to push through the output of stdout; that it somehow loses the browser open request. But reading through the docs, I don't see an alternate way to handle or forward shell command output.
Any guidance you can offer is most appreciated. Thank you!