Last active
October 28, 2015 02:17
-
-
Save geta6/1863dbecfbf5d3e8bce1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('exec', async () => { | |
const exec = { | |
exec(command, options) { | |
return new Promise((resolve, reject) => { | |
cp.spawn(command, options, {stdio: 'inherit'}).on('error', reject).on('exit', resolve); | |
}); | |
}, | |
async local(commands) { | |
await this.exec(process.env.SHELL, ['-c', commands.join('&&')]); | |
}, | |
async remote(commands) { | |
await this.exec('ssh', [process.env.REMOTE_HOST, commands.join('&&')]); | |
}, | |
}; | |
await exec.local([ | |
'pwd', | |
'ls', | |
]); | |
await exec.remote([ | |
'pwd', | |
'ls', | |
]); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gulp.task('exec', () => { | |
const exec = { | |
exec(command, options) { | |
return new Promise((resolve, reject) => { | |
cp.spawn(command, options, {stdio: 'inherit'}).on('error', reject).on('exit', resolve); | |
}); | |
}, | |
local(commands) { | |
return this.exec(process.env.SHELL, ['-c', commands.join('&&')]); | |
}, | |
remote(commands) { | |
return this.exec('ssh', [process.env.REMOTE_HOST, commands.join('&&')]); | |
}, | |
}; | |
exec.local([ | |
'pwd', | |
'ls', | |
]).then(() => { | |
return exec.remote([ | |
'pwd', | |
'ls', | |
]); | |
}).catch(err => { | |
console.error(err.stack); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment