Skip to content

Instantly share code, notes, and snippets.

@warrenday
Created June 22, 2018 10:36
Show Gist options
  • Select an option

  • Save warrenday/cbeec313f948f51cee7ea30890de41d9 to your computer and use it in GitHub Desktop.

Select an option

Save warrenday/cbeec313f948f51cee7ea30890de41d9 to your computer and use it in GitHub Desktop.
Watch for file changes of a local graphcool service and deploy on change.
const { spawn } = require('child_process');
const watch = require('node-watch');
let commandComplete = true;
watch([
'./src',
'graphcool.yml',
'types.graphql'
], { recursive: true }, function(evt, name) {
if (!commandComplete) {
// Do not run until last deploy has finished
return;
}
commandComplete = false
console.log('%s changed.', name);
// Run command to rebuild
const ls = spawn('graphcool', ['deploy'], {
stdio: 'inherit'
});
ls.on('exit', function (code) {
commandComplete = true
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment