Skip to content

Instantly share code, notes, and snippets.

@evan-007
Last active August 19, 2016 01:33
Show Gist options
  • Save evan-007/ec41e1cc7c8dc26b7f4e to your computer and use it in GitHub Desktop.
Save evan-007/ec41e1cc7c8dc26b7f4e to your computer and use it in GitHub Desktop.
gulp shell example
var gulp = require('gulp');
var connect = require('gulp-connect');
var modRewrite = require('connect-modrewrite');
var runSequence = require('run-sequence');
var shell = require('gulp-shell');
//proxy all requests to /api to localhost:3000 for rails api
gulp.task('connect', function(){
connect.server({
root: './app',
port: 8000,
middleware: function() {
return [
modRewrite([
'^/api/v1/(.*)$ http://localhost:3000/api/v1/$1 [P]'
])
];
}
});
});
//start rails server daemon
gulp.task('rails-start', shell.task([
'rails s -d'
]));
gulp.task('rails-kill', shell.task([
"kill `cat ../tmp/pids/server.pid`"
]));
//resets rails dev DB with seed.db data
gulp.task('db-setup', shell.task([
'bundle exec rake db:setup'
]));
//runs e2e tests
gulp.task('protractor', shell.task([
'protractor protractorConfig.js'
]));
gulp.task('e2e-test', function(){
// start servers, setup test db,
// run e2e tests,
// reset db, kill rails daemon
runSequence('rails-start', 'connect', 'db-setup', 'protractor',
'db-setup', 'rails-kill')
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment