| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 18758ef commit cc4a6ed
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,60 +36,12 @@ function rimrafSync(pathname, { spawn = true } = {}) { | |||
| 36 | 36 | } | |
| 37 | 37 | } | |
| 38 | 38 | ||
| 39 | - try { | ||
| 40 | - if (st.isDirectory()) | ||
| 41 | - rmdirSync(pathname, null); | ||
| 42 | - else | ||
| 43 | - fs.unlinkSync(pathname); | ||
| 44 | - } catch (e) { | ||
| 45 | - debug(e); | ||
| 46 | - switch (e.code) { | ||
| 47 | - case 'ENOENT': | ||
| 48 | - // It's not there anymore. Work is done. Exiting. | ||
| 49 | - return; | ||
| 50 | - | ||
| 51 | - case 'EPERM': | ||
| 52 | - // This can happen, try again with `rmdirSync`. | ||
| 53 | - break; | ||
| 54 | - | ||
| 55 | - case 'EISDIR': | ||
| 56 | - // Got 'EISDIR' even after testing `st.isDirectory()`... | ||
| 57 | - // Try again with `rmdirSync`. | ||
| 58 | - break; | ||
| 59 | - | ||
| 60 | - default: | ||
| 61 | - throw e; | ||
| 62 | - } | ||
| 63 | - rmdirSync(pathname, e); | ||
| 64 | - } | ||
| 39 | + fs.rmdirSync(pathname, { recursive: true, maxRetries: 5 }); | ||
| 65 | 40 | ||
| 66 | 41 | if (fs.existsSync(pathname)) | |
| 67 | 42 | throw new Error(`Unable to rimraf ${pathname}`); | |
| 68 | 43 | } | |
| 69 | 44 | ||
| 70 | - function rmdirSync(p, originalEr) { | ||
| 71 | - try { | ||
| 72 | - fs.rmdirSync(p); | ||
| 73 | - } catch (e) { | ||
| 74 | - if (e.code === 'ENOTDIR') | ||
| 75 | - throw originalEr; | ||
| 76 | - if (e.code === 'ENOTEMPTY' || e.code === 'EEXIST' || e.code === 'EPERM') { | ||
| 77 | - const enc = process.platform === 'linux' ? 'buffer' : 'utf8'; | ||
| 78 | - fs.readdirSync(p, enc).forEach((f) => { | ||
| 79 | - if (f instanceof Buffer) { | ||
| 80 | - const buf = Buffer.concat([Buffer.from(p), Buffer.from(path.sep), f]); | ||
| 81 | - rimrafSync(buf); | ||
| 82 | - } else { | ||
| 83 | - rimrafSync(path.join(p, f)); | ||
| 84 | - } | ||
| 85 | - }); | ||
| 86 | - fs.rmdirSync(p); | ||
| 87 | - return; | ||
| 88 | - } | ||
| 89 | - throw e; | ||
| 90 | - } | ||
| 91 | - } | ||
| 92 | - | ||
| 93 | 45 | const testRoot = process.env.NODE_TEST_DIR ? | |
| 94 | 46 | fs.realpathSync(process.env.NODE_TEST_DIR) : path.resolve(__dirname, '..'); | |
| 95 | 47 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments