diff options
author | Tomi Virkki <virkki@vaadin.com> | 2015-09-09 15:39:06 +0300 |
---|---|---|
committer | Tomi Virkki <virkki@vaadin.com> | 2015-09-09 15:39:06 +0300 |
commit | c393e9ce28a354dc6fe526193e016cdd3c016cad (patch) | |
tree | 49004e2704d4d7b6b6d5da9b308e856fead92b9e /tasks/common.js | |
parent | 08d870e3efdb05d9350aee714155be7b2b7eb6eb (diff) | |
download | vaadin-core-c393e9ce28a354dc6fe526193e016cdd3c016cad.tar.gz vaadin-core-c393e9ce28a354dc6fe526193e016cdd3c016cad.zip |
Added the tasks for publishing
Diffstat (limited to 'tasks/common.js')
-rw-r--r-- | tasks/common.js | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tasks/common.js b/tasks/common.js new file mode 100644 index 0000000..d4ba658 --- /dev/null +++ b/tasks/common.js @@ -0,0 +1,87 @@ +var args = require('yargs').argv; +var chalk = require('chalk'); +var wct = require('web-component-tester').test; +var _ = require('lodash'); +var gutil = require('gulp-util'); + +function cleanDone(done) { + return function(error) { + if (error) { + // Pretty error for gulp. + error = new Error(chalk.red(error.message || error)); + error.showStack = false; + } + done(error); + }; +} + +function checkArguments(arguments) { + _.forEach(arguments, function(a) { + if(!args.hasOwnProperty(a)) { + throw Error('Required argument \'--'+ a +'\' is missing.'); + } + }); +} + +function localAddress() { + var ip, tun, ifaces = require('os').networkInterfaces(); + Object.keys(ifaces).forEach(function (ifname) { + ifaces[ifname].forEach(function (iface) { + if ('IPv4' == iface.family && !iface.internal) { + if (!ip) ip = iface.address; + if (/tun/.test(ifname)) tun = iface.address; + } + }); + }); + return tun || ip; +} + +function test(options, done) { + wct(options, cleanDone(done)); +} + +module.exports = { + localAddress: localAddress, + test: test, + checkArguments: checkArguments, + + testSauce: function(suites, browsers, build, done) { + test( + { + suites: suites, + browserOptions: { + name: localAddress() + ' / ' + new Date(), + build: build + }, + + plugins: { + //local: { + // browsers: ['chrome'] + //}, + sauce: { + username: args.sauceUsername, + accessKey: args.sauceAccessKey, + browsers: browsers + }, + 'teamcity-reporter': args.teamcity + }, + webserver: { + hostname: localAddress() + } + }, done); + }, + + autoRevert: function(err, handler, done) { + if(err) { + gutil.log(err.toString()); + if(args.autoRevert) { + handler(); + } else { + gutil.log('No action. Use --auto-revert to revert changes.') + done(err); + } + } else { + done(); + } + } +}; |