forked from arenoir/ember-cli-deploy-rsync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
67 lines (57 loc) · 2.18 KB
/
index.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
/* jshint node: true */
'use strict';
var BasePlugin = require('ember-cli-deploy-plugin');
var Promise = require('rsvp').Promise;
var SilentError = require('silent-error');
var Rsync = require('rsyncwrapper');
module.exports = {
name: 'ember-cli-deploy-rsync',
createDeployPlugin: function(options) {
var DeployPlugin = BasePlugin.extend({
name: options.name,
defaultConfig: {
args: [],
delete: false,
deleteAll: false,
recursive: true
},
requiredConfig: ['dest'],
didBuild: function(context) {
// Do something amazing here once the project has been built
},
upload: function(context) {
this.log('Uploading using rsync...');
var options = {
src: context.distDir + '/',
dest: this.readConfig('dest'),
host: this.readConfig('host'),
ssh: this.readConfig('ssh'),
port: this.readConfig('port'),
privateKey: this.readConfig('privateKey'),
recursive: this.readConfig('recursive'),
delete: this.readConfig('delete'),
deleteAll: this.readConfig('deleteAll'),
args: this.readConfig('args')
};
var that = this;
return new Promise(function(resolve, reject) {
Rsync(options, function (error, stdout, stderr, cmd) {
if (error) {
that.log(cmd);
that.log(stdout);
that.log(stderr);
reject(new SilentError('Unable to sync! ' + error));
} else {
that.log(stdout);
resolve();
}
});
});
},
didDeploy: function(context) {
// Do something here like notify your team on slack
}
});
return new DeployPlugin();
}
}