Backdrop
I have a loopback and Angular app, Loopback gives use the server models and api's and using its sdk we are able to get client services.
Now i am planning to automate the following build process using gulp. If any changes in the model is made then the sdk command is run and also the server is restarted/ and secondly when any changes to the angular files the sdk files are run and files are fetched from angular dist folder and server is restarted and best possible we can use live reload of browser.
Here is what i have tried and this never seems to work have been working on this for days.
Update
I was able to automate most of the stuff the one place where it fails is
gulp.task('browser-sync', function() {
browserSync.init(null, {
proxy: 'http://localhost:3000/home',
browser: 'google chrome',
port: 7000,
});
gulp.watch(['client/src/app/*.ts'], browserSync.reload);
let watcher = gulp.watch(['./common/models/**.js', './server/**.js', 'gulpfile.js'], ['sdk', 'server']);
watcher.on('change', function(event) {
console.log('File ' + event.path + ' was ' + event.type + ', running tasks...'); // this watcher
});
});
gulp.task('sdk', function() {
spawn('./node_modules/.bin/lb-sdk', ['server/server.js', './client/src/app/shared/sdk', '-q'], {stdio: 'inherit'});
});
This watcher restarts the server and runs the sdk but it is failing in the sdk
The stack trace please help
via remoting. The Angular code for this scope won't be generated.
[19:29:37] Starting 'sdk'...
[19:29:37] Finished 'sdk' after 11 ms
[19:29:37] Starting 'server'...
[19:29:37] Finished 'server' after 17 ms
events.js:163
throw er; // Unhandled 'error' event
^
Error: spawn ./node_modules/.bin/lb-sdk ENOENT
at exports._errnoException (util.js:1050:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:367:16)
at _combinedTickCallback (internal/process/next_tick.js:80:11)
at process._tickCallback (internal/process/next_tick.js:104:9)
Update
I have multiple gulp task and one such is ng build -w
which happens in a new directory for the same i change the process.chdir
to change path and i also keep tab of this sdk so do i need to check the path again her . How can i check or give absolute paths in my spawn . if this is one of the probable causes of failure