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

chore(deps): drop mz dependency #3215

Merged
merged 7 commits into from
Aug 23, 2024
Merged

chore(deps): drop mz dependency #3215

merged 7 commits into from
Aug 23, 2024

Conversation

fregante
Copy link
Contributor

@fregante fregante commented Aug 4, 2024

https://github.com/normalize/mz

fs/promises is node v14+, no need for mz anymore.

Refer to the 2 existing review comments if you have questions.

@fregante fregante mentioned this pull request Aug 4, 2024
16 tasks
@fregante fregante changed the title Drop mz dependency chore(deps): drop mz dependency Aug 5, 2024
@fregante fregante marked this pull request as ready for review August 5, 2024 18:56
@@ -1,6 +1,7 @@
import path from 'path';
import nodeFs from 'fs';
import fs from 'fs/promises';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sometimes both APIs are used. For consistency, I let fs stay the promised API and used nodeFs for the other APIs. This name was actually used elsewhere too.

@@ -1,6 +1,7 @@
import path from 'path';
import fs from 'fs/promises';
import { writeFileSync } from 'fs';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In some cases I used the single export instead. This pattern was also already used in parts of the repo. However this is not always possible due to stubbing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense (and thanks a lot for mentioning the motivations behind these choices explicitly in this comment, that really helped to speed up the review and sign off ❤️)

@fregante
Copy link
Contributor Author

Due to the number of touched files, it would be good to merge this sooner rather than later

Copy link
Member

@rpl rpl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fregante thank you so much for these dependencies cleanup PRs, I just looked to this one and looks great. I'm signing it of as is and I'm going to be merging it right after.

Comment on lines 900 to 914
it('returns git commit information in development', function () {
return fs.exists(path.join(projectRoot, '.git')).then(async (exists) => {
if (!exists) {
return fs.access(path.join(projectRoot, '.git')).then(
async () => {
const commit = `${git.branch(projectRoot)}-${git.long(projectRoot)}`;
const testBuildEnv = { globalEnv: 'development' };
assert.equal(
await defaultVersionGetter(projectRoot, testBuildEnv),
commit,
);
},
() => {
this.skip();
}
const commit = `${git.branch(projectRoot)}-${git.long(projectRoot)}`;
const testBuildEnv = { globalEnv: 'development' };
assert.equal(
await defaultVersionGetter(projectRoot, testBuildEnv),
commit,
);
});
},
);
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: not really mandatory, but given that we need to touch this test case a bit then we may as well rewrite into an async function, and make it slightly more readable:

  it('returns git commit information in development', async function () {
    try {
      await fs.access(path.join(projectRoot, '.git'));
    } catch {
      this.skip();
      return;
    }
    const commit = `${git.branch(projectRoot)}-${git.long(projectRoot)}`;
    const testBuildEnv = { globalEnv: 'development' };
    assert.equal(
      await defaultVersionGetter(projectRoot, testBuildEnv),
      commit,
    );
  });

but I'd also like to merge this sooner rather than later, and in practice the test would be basically the same, and so we can eventually do that later after this is merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, in my PRs here I just limited my changes to the bare minimum to avoid unnecessary bikeshedding.

I think both this repo and addons-linter would benefit from a strict lint config and a whole bunch of rules (like eslint-plugin-unicorn) with autofixes.

Your suggestion is https://github.com/eslint-community/eslint-plugin-promise/blob/main/docs/rules/prefer-await-to-then.md

@@ -1,6 +1,7 @@
import path from 'path';
import fs from 'fs/promises';
import { writeFileSync } from 'fs';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense (and thanks a lot for mentioning the motivations behind these choices explicitly in this comment, that really helped to speed up the review and sign off ❤️)

@rpl rpl merged commit 3b8d1df into mozilla:master Aug 23, 2024
4 checks passed
@fregante fregante deleted the bye-mz branch August 23, 2024 11:30
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.

2 participants