aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/common.js
blob: dd2252088cc65eb81f232cf0a96ef1c2cd5287eb (plain)
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
var args = require('yargs').argv;
var _ = require('lodash');
var gutil = require('gulp-util');
var config = require('./config');

function checkArguments(arguments) {
  _.forEach(arguments, function(a) {
    if(!args.hasOwnProperty(a)) {
      throw Error('Required argument \'--'+ a +'\' is missing.');
    }
  });
}

function ssh(user, host, command, done) {
  gutil.log('SSH: ' + host + ' -> ' + command);
  require('node-ssh-exec')({
      host: host,
      username: user,
      privateKey: config.paths.privateKey()
    }, command, done);
}

module.exports = {
  ssh: ssh,
  checkArguments: checkArguments
};