-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.js
35 lines (29 loc) · 840 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
32
33
34
35
#!/usr/bin/env node
const args = process.argv.slice(2)
if (args.length === 0) {
const dotenv = require('dotenv')
dotenv.config()
}
const FtpDeploy = require('ftp-deploy')
const path = require('path')
const ftp = new FtpDeploy()
if (process.env.FTP_USER && process.env.FTP_PASS && process.env.FTP_HOST) {
const config = {
user: process.env.FTP_USER,
password: process.env.FTP_PASS,
host: process.env.FTP_HOST,
port: 21,
localRoot: path.join(__dirname, 'dist'),
remoteRoot: '/',
include: ['*.html', '*.css', '*.pdf', '*.svg', '*.jpg'],
deleteRemote: true,
forcePasv: true,
}
ftp
.deploy(config)
.then(result => console.log(`Finished:\n${result[0].join('\n')}`))
.catch(error => console.log(error))
} else {
console.error('Couldn\'t find needful env vars')
process.exit(1)
}