Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace fibers with async/await #182

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

LeoDT
Copy link

@LeoDT LeoDT commented Jan 13, 2022

what's done:

  1. upgrade node requirement to 12
  2. upgrade dependencies
  3. replace fibers with async/await
  4. replace util.inherits with class for the transports(removed some related tests)
  5. removed unable to load module error handler from bin.js, it is no longer thrown when requiring a ts file
  6. use nyc instead of istanbul
  7. tests seem OK
  8. small real-world tests seem OK

what's not done:

  • use class in errors.js and transport/index.js
  • more real-world tests(with private projects)
  • 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.

@pstadler
Copy link
Owner

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?

@LeoDT
Copy link
Author

LeoDT commented Jan 14, 2022

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 LeoDT marked this pull request as ready for review January 18, 2022 01:10
@LeoDT LeoDT changed the title [WIP] replace fibers with async/await replace fibers with async/await Jan 18, 2022
@Zwimber
Copy link

Zwimber commented May 8, 2022

@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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants