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

fix: replace fs-extra.ensureFileSync with fs.writeFileSync #1790

Merged
merged 2 commits into from
Mar 21, 2025

Conversation

erisu
Copy link
Member

@erisu erisu commented Mar 21, 2025

Motivation and Context

Fix undefined ensureFileSync method.

Description

The fs-extra npm package was removed which caused ensureFileSync to be not a function.

This PR replaces ensureFileSync with writeFileSync. The signing properties file is always removed before being recreated, and the platform directory should always exist, so it should be safe to call writeFileSync.

Testing

  • npm t
  • created a testing debug keystore file
  • configured build.json to use the testing debug keystore.
  • cordova build android
  • cordova run android

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@codecov-commenter
Copy link

codecov-commenter commented Mar 21, 2025

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 71.89%. Comparing base (839f9b8) to head (b8e1d8f).

Files with missing lines Patch % Lines
lib/builders/ProjectBuilder.js 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1790   +/-   ##
=======================================
  Coverage   71.89%   71.89%           
=======================================
  Files          23       23           
  Lines        1854     1854           
=======================================
  Hits         1333     1333           
  Misses        521      521           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@dpogue dpogue left a comment

Choose a reason for hiding this comment

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

This looks fine to me.

With regards to the filesystem race condition, since we always overwrite the file if opts.packageInfo is set, is it fine to move the deletion to an else block and do it with { force: true } so we don't need to check existence?

Copy link
Contributor

@breautek breautek left a comment

Choose a reason for hiding this comment

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

lgtm

@erisu erisu merged commit f6e384a into apache:master Mar 21, 2025
8 checks passed
@erisu erisu deleted the fix/signing-properties-creation branch March 21, 2025 15:45
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.

4 participants