-
-
Notifications
You must be signed in to change notification settings - Fork 37.4k
fs: remove IIFE in glob #58418
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
fs: remove IIFE in glob #58418
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,6 +34,7 @@ const { | |
| ObjectDefineProperties, | ||
| ObjectDefineProperty, | ||
| Promise, | ||
| PromisePrototypeThen, | ||
| PromiseResolve, | ||
| ReflectApply, | ||
| SafeMap, | ||
|
|
@@ -3171,15 +3172,11 @@ function glob(pattern, options, callback) { | |
| callback = makeCallback(callback); | ||
|
|
||
| const Glob = lazyGlob(); | ||
| // TODO: Use iterator helpers when available | ||
| (async () => { | ||
| try { | ||
| const res = await ArrayFromAsync(new Glob(pattern, options).glob()); | ||
| callback(null, res); | ||
| } catch (err) { | ||
| callback(err); | ||
| } | ||
| })(); | ||
| PromisePrototypeThen( | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the catch?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the second argument to |
||
| ArrayFromAsync(new Glob(pattern, options).glob()), | ||
| (res) => callback(null, res), | ||
| callback, | ||
| ); | ||
| } | ||
|
|
||
| function globSync(pattern, options) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { mustCall } from '../common/index.mjs'; | ||
| import { glob } from 'node:fs'; | ||
| import process from 'node:process'; | ||
| import { strictEqual } from 'node:assert'; | ||
|
|
||
| // One uncaught error is expected | ||
| process.on('uncaughtException', mustCall((err) => { | ||
| strictEqual(err.message, 'blep'); | ||
| })); | ||
|
|
||
| { | ||
| // Test that if callback throws, it's not getting called again | ||
| glob('a/b/c', mustCall(() => { | ||
| throw new Error('blep'); | ||
| })); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: this TODO was added in 151d365 and already resolved in 090add7