Created
June 22, 2018 10:36
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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