electron-userland / electron-installer-dmg

Create DMG installers for your electron apps using appdmg.
https://github.com/electron-userland/electron-installer-dmg
Apache License 2.0
322 stars 39 forks source link

refactor: `fs.rmdir` -> `fs.rm` #133

Closed erickzhao closed 3 months ago

erickzhao commented 2 years ago
(node:23706) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use `node --trace-deprecation ...` to show where the warning was created)

Node 16: https://nodejs.org/api/deprecations.html#DEP0147

codecov[bot] commented 2 years ago

Codecov Report

Merging #133 (d9354ee) into main (29e44a6) will not change coverage. The diff coverage is 100.00%.

:exclamation: Current head d9354ee differs from pull request most recent head 3f0503b. Consider uploading reports for the commit 3f0503b to get more accurate results

@@           Coverage Diff           @@
##             main     #133   +/-   ##
=======================================
  Coverage   75.43%   75.43%           
=======================================
  Files           1        1           
  Lines          57       57           
=======================================
  Hits           43       43           
  Misses         14       14           
Impacted Files Coverage Δ
src/index.js 75.43% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 29e44a6...3f0503b. Read the comment docs.

malept commented 2 years ago
  1. Why didn't CI run for this PR? :confused:
  2. fs.rm doesn't exist until Node 14, I think?
eXhumer commented 5 months ago

I came across a deprecation warning (node:88445) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead while trying to build darwin DMGs for my Electron app.

fsPromises.rm was added since 14.14.0 update. A check for the runtime node version using process.versions.node can be used to select the correct method

      const nodeVersion = process.versions.node.split('.').map(segment => parseInt(segment));
      await (nodeVersion[0] > 14 || (nodeVersion[0] === 14 && nodeVersion[1] >= 14) ?
        fs.rm :
        fs.rmdir)(specDir, { recursive: true, maxRetries: 2 });

NOTE: fsPromises.rmdir was added in v10.0.0, recursive was added since v12.10.0

erickzhao commented 4 months ago

Will merge this after https://github.com/electron-userland/electron-installer-dmg/pull/178