-
Notifications
You must be signed in to change notification settings - Fork 861
/
ftpdeploy.js
48 lines (40 loc) · 1.17 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
/* eslint-disable no-empty-label */
'use strict';
const FtpDeploy = require('ftp-deploy');
const path = require('path');
function deploy(ftpDetails, appFolder, done) {
const ftpDeploy = new FtpDeploy();
const config = {
username: ftpDetails.user,
password: ftpDetails.pass, // optional, prompted if none given
host: ftpDetails.host,
port: ftpDetails.port,
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
};