| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,6 +34,7 @@ const { | |||
| 34 | 34 | ObjectDefineProperties, | |
| 35 | 35 | ObjectDefineProperty, | |
| 36 | 36 | Promise, | |
| 37 | + PromisePrototypeThen, | ||
| 37 | 38 | PromiseResolve, | |
| 38 | 39 | ReflectApply, | |
| 39 | 40 | SafeMap, | |
@@ -3175,15 +3176,11 @@ function glob(pattern, options, callback) { | |||
| 3175 | 3176 | callback = makeCallback(callback); | |
| 3176 | 3177 | ||
| 3177 | 3178 | const Glob = lazyGlob(); | |
| 3178 | - // TODO: Use iterator helpers when available | ||
| 3179 | - (async () => { | ||
| 3180 | - try { | ||
| 3181 | - const res = await ArrayFromAsync(new Glob(pattern, options).glob()); | ||
| 3182 | - callback(null, res); | ||
| 3183 | - } catch (err) { | ||
| 3184 | - callback(err); | ||
| 3185 | - } | ||
| 3186 | - })(); | ||
| 3179 | + PromisePrototypeThen( | ||
| 3180 | + ArrayFromAsync(new Glob(pattern, options).glob()), | ||
| 3181 | + (res) => callback(null, res), | ||
| 3182 | + callback, | ||
| 3183 | + ); | ||
| 3187 | 3184 | } | |
| 3188 | 3185 | ||
| 3189 | 3186 | function globSync(pattern, options) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,16 @@ | |||
| 1 | + import { mustCall } from '../common/index.mjs'; | ||
| 2 | + import { glob } from 'node:fs'; | ||
| 3 | + import process from 'node:process'; | ||
| 4 | + import { strictEqual } from 'node:assert'; | ||
| 5 | + | ||
| 6 | + // One uncaught error is expected | ||
| 7 | + process.on('uncaughtException', mustCall((err) => { | ||
| 8 | + strictEqual(err.message, 'blep'); | ||
| 9 | + })); | ||
| 10 | + | ||
| 11 | + { | ||
| 12 | + // Test that if callback throws, it's not getting called again | ||
| 13 | + glob('a/b/c', mustCall(() => { | ||
| 14 | + throw new Error('blep'); | ||
| 15 | + })); | ||
| 16 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments