flightplan
flightplan copied to clipboard
replace fibers with async/await
what's done:
- upgrade node requirement to 12
- upgrade dependencies
- replace fibers with async/await
- replace
util.inheritswithclassfor the transports(removed some related tests) - removed
unable to load moduleerror handler frombin.js, it is no longer thrown when requiring atsfile - use
nycinstead ofistanbul - tests seem OK
- small real-world tests seem OK
what's not done:
- [x] use
classinerrors.jsandtransport/index.js - [x] more real-world tests(with private projects)
- [x] docs
after this change, the old API will not work, we need to add await before every exec related function when defining the tasks, but this makes the flightplan.js file more like a normal js file, users can use async/await in the task defines which they can not do in the fibers version.
const plan = require('flightplan');
async function fetchSomthing() {
return` Promise.resolve('remote hello');
}
plan.target('default', {
//...
});
plan.local(async (local) => {
await local.echo('hello');
await local.transfer('fileA', '~/');
});
plan.remote(async (remote) => {
remote.log('log');
await remote.with('cd ~/', async () => {
await remote.mv('./fileA ./fileB');
});
const foo = await fetchSomething();
await remote.echo(foo);
});
I'm not sure if this is good for everyone, but I'll submit this first and see what will come up.
Thanks a lot for this effort! This looks really good so far. Would you be interested in keeping this project alive and well maintained after your rewrite?
I don't have much experience in maintaining open source projects, if this is OK for you, maybe I can give it a try.
@LeoDT thanks for updating this, we've been struggling with not being able to update to a recent Node.JS version.
For those that want to use it before merge:
npm install --save-dev "git://github.com/pstadler/flightplan.git#571fca5a465d4f7cd11ee258bb59d3cb594b0782"