Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to run `ionic serve` from Gulp script

I am trying to setup end to end tests using protractor and gulp. So in order to execute my tests on the CI server I will need spin off a server which serves ionic my html/js/css.

I am not entirely sure how ionic cli triggers the server, does it have some sort of task runner under the hood? If so, could I trigger it from the gulp script?

like image 440
Vitalij Avatar asked May 09 '26 15:05

Vitalij


1 Answers

This is not the most elegant way but I believe this gets the job done.

First include child-process in your gulpfile.js

var exec = require('child_process').exec;

Create a new gulp task startServer like

gulp.task('startServer', function(){
    exec('ionic serve', function (err, stdout, stderr) {});
});

Pass this new task to your default task like,

gulp.task('default', [/*'task1','task2',...,*/'startServer']);

Then simply run gulp instead of ionic serve and you're all set.

Hope that helps. :)

like image 200
AdityaParab Avatar answered May 12 '26 12:05

AdityaParab



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!