Skip to content

Commit d650ab9

Browse files
author
Daniele Sabre
committed
Develop
1 parent 3051455 commit d650ab9

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

bin/deploy-ftp.js

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,6 @@ require('dotenv').config({path: cwd + '/.env.local'});
1212

1313
console.log(chalk.bgYellow(chalk.black(`- DEPLOY PROJECT ${projectJson.name} -`)));
1414

15-
// set mail constants
16-
const FTP_USER = process.env.DSDEPLOY_FTP_USER;
17-
const FTP_HOST = process.env.DSDEPLOY_FTP_HOST;
18-
const FTP_PORT = process.env.DSDEPLOY_FTP_PORT || 21;
19-
const FTP_PASSWORD = process.env.DSDEPLOY_FTP_PASSWORD;
20-
const FTP_REMOTE_DIR = process.env.DSDEPLOY_FTP_REMOTE_DIR || cwd.split('/').reverse()[0];
21-
2215
// build project
2316
console.log(chalk.cyan('\nBuilding project...'));
2417
execSync('npm run build');
@@ -44,20 +37,20 @@ const deleteBuild = () => {
4437

4538
// ftp configuration
4639
const config = {
47-
user: FTP_USER,
48-
host: FTP_HOST,
49-
port: FTP_PORT,
40+
user: process.env.DSDEPLOY_FTP_USER,
41+
host: process.env.DSDEPLOY_FTP_HOST,
42+
port: process.env.DSDEPLOY_FTP_PORT || 21,
5043
localRoot: localDir,
51-
remoteRoot: `/${FTP_REMOTE_DIR}/`,
44+
remoteRoot: '/' + (process.env.DSDEPLOY_FTP_REMOTE_DIR || cwd.split('/').reverse()[0]) + '/',
5245
include: ["*", "**/*"], // this would upload everything except dot files
53-
deleteRemote: false, // delete ALL existing files at destination before uploading, if true
54-
forcePasv: true, // Passive mode is forced (EPSV command is not sent)
55-
sftp: false // use sftp or ftp
46+
deleteRemote: parseInt(process.env.DSDEPLOY_FTP_DELETE_REMOTE) === 1, // delete ALL existing files at destination before uploading, if true
47+
forcePasv: typeof process.env.DSDEPLOY_FTP_FORCE_PASSIVE_MODE !== 'undefined' ? parseInt(process.env.DSDEPLOY_FTP_FORCE_PASSIVE_MODE) === 1 : true, // Passive mode is forced (EPSV command is not sent)
48+
sftp: parseInt(process.env.DSDEPLOY_FTP_USE_SFTP) === 1 // use sftp or ftp
5649
};
5750

5851
// Password optional, prompted if none given
59-
if (FTP_PASSWORD) {
60-
config.password = FTP_PASSWORD;
52+
if (process.env.DSDEPLOY_FTP_PASSWORD) {
53+
config.password = process.env.DSDEPLOY_FTP_PASSWORD;
6154
}
6255

6356
console.log(chalk.cyan('\nFTP deploy configuration:'));

0 commit comments

Comments
 (0)