-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy.js
31 lines (28 loc) · 930 Bytes
/
deploy.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
const ftp = require('basic-ftp');
var ftpDeployConfig = require('./ftpDeployConfig.js');
deploy()
async function deploy() {
console.log(`~~~~~~~~~~~~~~~~~~~~~~~~~~~~`);
console.log(`> deploy to "${ftpDeployConfig.config.host}"`);
console.log(`> sourcePath --> ${ftpDeployConfig.config.sourcePath}`);
console.log(`> remotePath --> ${ftpDeployConfig.config.remotePath}`);
const client = new ftp.Client();
client.ftp.verbose = true;
try {
await client.access({
host: ftpDeployConfig.config.host,
user: ftpDeployConfig.config.user,
password: ftpDeployConfig.config.password,
secure: false,
forcePasv: true
});
console.log(await client.list());
await client.ensureDir(ftpDeployConfig.config.remotePath);
await client.clearWorkingDir();
await client.uploadFromDir(ftpDeployConfig.config.sourcePath);
}
catch(err) {
console.log(err)
}
client.close();
}