forked from angular-resource-sails/angular-resource-sails
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
79 lines (63 loc) · 1.97 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
var gulp = require('gulp');
var spawn = require('child_process').spawn;
var protractor = require("gulp-protractor").protractor;
var webdriver_update = require("gulp-protractor").webdriver_update;
var fs = require('fs');
var path = require('path');
var sailsProcess;
gulp.task('remove-local-sails-db', function (cb) {
var dbLocation = path.join('example', '.tmp', 'localDiskDb.db');
fs.unlink(dbLocation, function (err) {
if (err) {
console.log('no database file, no worries');
} else {
console.log('successfully deleted /tmp/hello');
}
cb();
});
});
gulp.task('sails-lift', ['remove-local-sails-db'], function (cb) {
var sails = (process.platform === "win32" ? "sails.cmd" : "sails");
sailsProcess = spawn(sails, ['lift'], {cwd: './example'});
sailsProcess.stdout.on('data', function (data) {
console.log(data.toString());
// sails lifted, lets go
if (data.toString().indexOf('Server lifted') > -1) {
cb();
}
});
sailsProcess.stderr.on('data', function (data) {
console.log('e: ' + data);
});
});
gulp.task('webdriver_update', webdriver_update);
gulp.task('protractor-read', ['sails-lift', 'webdriver_update'], function (cb) {
runProtractor('read', cb);
});
gulp.task('protractor-write', ['sails-lift', 'webdriver_update'], function (cb) {
runProtractor('write', cb);
});
gulp.task('protractor', ['protractor-read', 'protractor-write'], function () {
sailsProcess.kill('SIGINT');
});
gulp.task('default', ['protractor']);
// for some reason gulp has a hard time closing when using protractor
// this helps force it
gulp.doneCallback = function (err) {
process.exit(err ? 1 : 0);
};
function runProtractor(suite, cb) {
var configFile = "protractor.conf.js";
if (process.env.ci) {
configFile = "protractor-ci.conf.js";
}
gulp.src(["./e2e/*.js"])
.pipe(protractor({
configFile: configFile,
args: ['--baseUrl', 'http://localhost:1337', '--suite', suite]
}))
.on('error', function (e) {
sailsProcess.kill('SIGINT');
cb(e);
}).on('end', cb);
}