forked from fossasia/open-event-wsgen
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ftpdeploy.js
48 lines (41 loc) · 1.18 KB
/
ftpdeploy.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
/**
* Created by championswimmer on 15/8/16.
*/
"use strict";
var FtpDeploy = require('ftp-deploy');
var path = require('path');
function deploy(ftpDetails, appFolder, done) {
var ftpDeploy = new FtpDeploy();
var config = {
username: ftpDetails.user,
password: ftpDetails.pass, // optional, prompted if none given
host: ftpDetails.host,
port: 21,
localRoot: path.join(__dirname, '/../../dist', appFolder),
remoteRoot: ftpDetails.path,
exclude: ['.git', '.idea', 'tmp/*'],
continueOnError: true
};
ftpDeploy.on('upload-error', function (data) {
console.log(data.err); // data will also include filename, relativePath, and other goodies
});
ftpDeploy.on('uploaded', function(data) {
console.log(data); // same data as uploading event
});
ftpDeploy.on('uploading', function(data) {
console.log(data); // same data as uploading event
});
ftpDeploy.on('error', function(data) {
console.log(data); // same data as uploading event
});
ftpDeploy.deploy(config, function(err) {
if (err) { console.log(err); }
else {
console.log('finished');
done();
}
});
}
module.exports = {
deploy
};