-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeploy.js
More file actions
36 lines (27 loc) · 1015 Bytes
/
deploy.js
File metadata and controls
36 lines (27 loc) · 1015 Bytes
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
// @ts-check
const logger = require("./logger");
const configHelper = require("./configHelper");
const execSync = require("child_process").execSync;
/**
* User credentials --- Remove this
* TODO: Ask for username/password
*/
const username = "root";
const password = "";
function deploy(config) {
try {
const { server } = config;
const hostName = configHelper.getHostName(server);
const localDir = configHelper.getLocalDeployDir();
const remoteDir = configHelper.getRemoteDeployDir();
const command = `scp -r ${localDir} ${username}@${hostName}:${password}${remoteDir}`
logger.info(` ------ Starting deploying to server: ${hostName} --------`);
const stdout = execSync(command, { stdio: "inherit" });
logger.info("-------------\n" + stdout);
logger.info(` ------ Done deploying to server: ${hostName} --------`);
} catch (ex) {
logger.error(` ---- Error while deploying to server ------ ${ex.toString()}`);
throw ex;
}
}
module.exports = deploy;