How to run an "ion feed" from a Gulp script

I am trying to set up end-to-end tests using protractor and gulp. So in order to run my tests on a CI server, I will need to spin up the server that serves the ionic html / js / css.

I'm not really sure how the ionic cli starts the server, does it have some kind of task runner under the hood? If so, can I run it from a gulp script?

+3


source to share


2 answers


This is not the most elegant way, but I believe it does the job.

First include child-process

ingulpfile.js

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

Create a new gulp task startServer

as

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

      



Submit this new task to your default task, for example

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

Then just run gulp

instead ionic serve

and you're all set.

Hope it helps. :)

+1


source


As you can read here: http://www.reddit.com/r/ionic/comments/362log/how_does_ionic_serve_all_work/ , it starts its own web server (for example when using WAMPP or XAMPP).

So I actually went to check it out, and it really is; if you are familiar with XAMPP or WAMPP you can run your ionic project inside the www

WAMPP folder and then you can access it via http: // localhost / myapp / www (without using the ionic feed command) if you run your ionic app using ionic run myapp.



I'm not familiar with Gulp, but you can see if this plugin https://www.npmjs.com/package/gulp-live-server will help you get your task done.

0


source







All Articles