Skip to content

build/fs: modernize file-system helpers #4933

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mohiuddin-khan-shiam
Copy link

Replaced custom recursive directory creation and deprecated fs.rmdirSync logic with the native APIs introduced in Node ≥10:

  • ensureDir now calls fs.mkdirSync(dirname, { recursive: true })
    – creates full path atomically
    – avoids race conditions and extra loops

  • removeDir now ends with fs.rmSync(dirPath, { recursive: true, force: true })
    – officially supported replacement for fs.rmdirSync
    – handles non-empty directories and future Node versions

This simplifies the code, removes deprecation warnings on Node 16+, and prevents build/packaging scripts from failing on newer runtimes.

odiomarcelino and others added 2 commits June 29, 2025 18:18
Replaced custom recursive directory creation and deprecated `fs.rmdirSync` logic with the native APIs introduced in Node ≥10:

* [ensureDir](cci:1://file:///c:/Users/T2430514/Downloads/monaco-editor/build/fs.ts:12:0-21:1) now calls `fs.mkdirSync(dirname, { recursive: true })`
  – creates full path atomically
  – avoids race conditions and extra loops

* [removeDir](cci:1://file:///c:/Users/T2430514/Downloads/monaco-editor/build/fs.ts:44:0-79:1) now ends with `fs.rmSync(dirPath, { recursive: true, force: true })`
  – officially supported replacement for `fs.rmdirSync`
  – handles non-empty directories and future Node versions

This simplifies the code, removes deprecation warnings on Node 16+, and prevents build/packaging scripts from failing on newer runtimes.

Co-Authored-By: S. M. Mohiuddin Khan Shiam <147746955+mohiuddin-khan-shiam@users.noreply.github.com>
Replaced custom recursive directory creation and deprecated `fs.rmdirSync` logic with the native APIs introduced in Node ≥10:

* [ensureDir](cci:1://file:///c:/Users/T2430514/Downloads/monaco-editor/build/fs.ts:12:0-21:1) now calls `fs.mkdirSync(dirname, { recursive: true })`  
  – creates full path atomically  
  – avoids race conditions and extra loops

* [removeDir](cci:1://file:///c:/Users/T2430514/Downloads/monaco-editor/build/fs.ts:44:0-79:1) now ends with `fs.rmSync(dirPath, { recursive: true, force: true })`  
  – officially supported replacement for `fs.rmdirSync`  
  – handles non-empty directories and future Node versions

This simplifies the code, removes deprecation warnings on Node 16+, and prevents build/packaging scripts from failing on newer runtimes.
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