mirror of
https://github.com/easingthemes/ssh-deploy.git
synced 2025-06-22 04:22:10 +10:00
Use promise
This commit is contained in:
parent
7306f6bca0
commit
fdc1b9a24d
4 changed files with 83 additions and 74 deletions
29
src/index.js
29
src/index.js
|
@ -5,7 +5,7 @@ const { addSshKey, getPrivateKeyPath } = require('./sshKey');
|
|||
const { validateRequiredInputs } = require('./helpers');
|
||||
const inputs = require('./inputs');
|
||||
|
||||
const run = () => {
|
||||
const run = async () => {
|
||||
const {
|
||||
source, remoteUser, remoteHost, remotePort,
|
||||
deployKeyName, sshPrivateKey,
|
||||
|
@ -20,20 +20,25 @@ const run = () => {
|
|||
const { path: privateKeyPath } = getPrivateKeyPath(deployKeyName);
|
||||
// Check Script before
|
||||
if (scriptBefore) {
|
||||
remoteCmdBefore(scriptBefore);
|
||||
}
|
||||
// Check script after
|
||||
let callback = () => {};
|
||||
if (scriptAfter) {
|
||||
callback = (...result) => {
|
||||
remoteCmdAfter(scriptAfter, result);
|
||||
};
|
||||
await remoteCmdBefore(scriptBefore);
|
||||
}
|
||||
|
||||
/* eslint-disable object-property-newline */
|
||||
sshDeploy({
|
||||
await sshDeploy({
|
||||
source, rsyncServer, exclude, remotePort,
|
||||
privateKeyPath, args, sshCmdArgs, callback
|
||||
privateKeyPath, args, sshCmdArgs
|
||||
});
|
||||
|
||||
// Check script after
|
||||
if (scriptAfter) {
|
||||
await remoteCmdAfter(scriptAfter);
|
||||
}
|
||||
};
|
||||
|
||||
run();
|
||||
run()
|
||||
.then(() => {
|
||||
console.log('DONE');
|
||||
})
|
||||
.catch(() => {
|
||||
console.error('ERROR');
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue