@pnpm/fs.graceful-fs 1100.1.0 → 1100.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/lib/index.d.ts +29 -19
- package/lib/index.js +36 -0
- package/package.json +8 -5
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# @pnpm/fs.graceful-fs
|
|
2
|
+
|
|
3
|
+
## 1100.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Copying a built package to its other hoisted locations no longer replaces the destination directory. With `nodeLinker: hoisted`, that replacement deleted the dependencies nested inside the destination's `node_modules`, and made concurrent copies of the same build chunk fail with `ERR_PNPM_ENOENT: no such file or directory, rename '.../node_modules/_tmp_...'` [#12880](https://github.com/pnpm/pnpm/issues/12880).
|
|
8
|
+
|
|
9
|
+
## 1100.1.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Republished every package: the tarballs published by the v11.13.1 through v11.16.0 releases were missing most of their compiled files due to a packing bug [#13164](https://github.com/pnpm/pnpm/issues/13164).
|
package/lib/index.d.ts
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from 'node:fs';
|
|
2
2
|
declare const _default: {
|
|
3
|
-
chmod: typeof
|
|
4
|
-
copyFile: typeof
|
|
5
|
-
copyFileSync: (src:
|
|
6
|
-
createReadStream: typeof
|
|
7
|
-
link: typeof
|
|
8
|
-
linkSync: (existingPath:
|
|
9
|
-
mkdir: typeof
|
|
10
|
-
mkdirSync: (path:
|
|
11
|
-
renameSync: (oldPath:
|
|
12
|
-
readFile: typeof
|
|
13
|
-
readFileSync: typeof
|
|
14
|
-
readdirSync: typeof
|
|
15
|
-
stat: typeof
|
|
16
|
-
statSync:
|
|
17
|
-
unlink: typeof
|
|
18
|
-
unlinkSync: typeof
|
|
19
|
-
writeFile: typeof
|
|
20
|
-
writeFileSync: (file:
|
|
3
|
+
chmod: typeof fs.chmod.__promisify__;
|
|
4
|
+
copyFile: typeof fs.copyFile.__promisify__;
|
|
5
|
+
copyFileSync: (src: fs.PathLike, dest: fs.PathLike, mode?: number | undefined) => void;
|
|
6
|
+
createReadStream: typeof fs.createReadStream;
|
|
7
|
+
link: typeof fs.link.__promisify__;
|
|
8
|
+
linkSync: (existingPath: fs.PathLike, newPath: fs.PathLike) => void;
|
|
9
|
+
mkdir: typeof fs.mkdir.__promisify__;
|
|
10
|
+
mkdirSync: (path: fs.PathLike, options?: fs.MakeDirectoryOptions | fs.Mode | null | undefined) => string | undefined;
|
|
11
|
+
renameSync: (oldPath: fs.PathLike, newPath: fs.PathLike) => void;
|
|
12
|
+
readFile: typeof fs.readFile.__promisify__;
|
|
13
|
+
readFileSync: typeof fs.readFileSync;
|
|
14
|
+
readdirSync: typeof fs.readdirSync;
|
|
15
|
+
stat: typeof fs.stat.__promisify__;
|
|
16
|
+
statSync: fs.StatSyncFn;
|
|
17
|
+
unlink: typeof fs.unlink.__promisify__;
|
|
18
|
+
unlinkSync: typeof fs.unlinkSync;
|
|
19
|
+
writeFile: typeof fs.writeFile.__promisify__;
|
|
20
|
+
writeFileSync: (file: fs.PathOrFileDescriptor, data: string | NodeJS.ArrayBufferView<ArrayBufferLike>, options?: fs.WriteFileOptions | undefined) => void;
|
|
21
21
|
};
|
|
22
22
|
export default _default;
|
|
23
|
+
/**
|
|
24
|
+
* Renames `src` over `dest`, waiting out a Windows sharing violation — an
|
|
25
|
+
* EPERM, EACCES or EBUSY from whoever else holds the file open — for up to a
|
|
26
|
+
* minute before rethrowing it. Every other error is thrown right away.
|
|
27
|
+
*
|
|
28
|
+
* `dest` is never removed to make room for the rename: a concurrent install may
|
|
29
|
+
* still be reading that dirent, and a reader has to see either the whole file
|
|
30
|
+
* that was there or the whole file replacing it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function renameFileWithRetry(src: string, dest: string): void;
|
package/lib/index.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
1
2
|
import util, { promisify } from 'node:util';
|
|
2
3
|
import gfs from 'graceful-fs';
|
|
4
|
+
const RENAME_RETRY_BUDGET_MS = 60_000;
|
|
5
|
+
const RENAME_RETRY_BACKOFF_CAP_MS = 100;
|
|
6
|
+
const renameRetrySleepBuffer = new Int32Array(new SharedArrayBuffer(4));
|
|
3
7
|
export default {
|
|
4
8
|
chmod: promisify(gfs.chmod),
|
|
5
9
|
copyFile: promisify(gfs.copyFile),
|
|
@@ -41,4 +45,36 @@ function withEagainRetry(fn, maxRetries = 15) {
|
|
|
41
45
|
throw new Error('Unreachable');
|
|
42
46
|
};
|
|
43
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* Renames `src` over `dest`, waiting out a Windows sharing violation — an
|
|
50
|
+
* EPERM, EACCES or EBUSY from whoever else holds the file open — for up to a
|
|
51
|
+
* minute before rethrowing it. Every other error is thrown right away.
|
|
52
|
+
*
|
|
53
|
+
* `dest` is never removed to make room for the rename: a concurrent install may
|
|
54
|
+
* still be reading that dirent, and a reader has to see either the whole file
|
|
55
|
+
* that was there or the whole file replacing it.
|
|
56
|
+
*/
|
|
57
|
+
export function renameFileWithRetry(src, dest) {
|
|
58
|
+
const startedAt = Date.now();
|
|
59
|
+
let backoffMs = 0;
|
|
60
|
+
for (;;) {
|
|
61
|
+
try {
|
|
62
|
+
fs.renameSync(src, dest);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
if (!isTransientRenameError(err) || Date.now() - startedAt >= RENAME_RETRY_BUDGET_MS)
|
|
67
|
+
throw err;
|
|
68
|
+
if (backoffMs > 0)
|
|
69
|
+
Atomics.wait(renameRetrySleepBuffer, 0, 0, backoffMs);
|
|
70
|
+
backoffMs = Math.min(backoffMs + 10, RENAME_RETRY_BACKOFF_CAP_MS);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function isTransientRenameError(err) {
|
|
75
|
+
return process.platform === 'win32' &&
|
|
76
|
+
util.types.isNativeError(err) &&
|
|
77
|
+
'code' in err &&
|
|
78
|
+
(err.code === 'EPERM' || err.code === 'EACCES' || err.code === 'EBUSY');
|
|
79
|
+
}
|
|
44
80
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pnpm/fs.graceful-fs",
|
|
3
|
-
"version": "1100.
|
|
3
|
+
"version": "1100.2.0",
|
|
4
4
|
"description": "Promisified graceful-fs",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pnpm",
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
],
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"funding": "https://opencollective.com/pnpm",
|
|
11
|
-
"repository":
|
|
12
|
-
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "https://github.com/pnpm/pnpm/tree/main/pnpm11/fs/graceful-fs"
|
|
14
|
+
},
|
|
15
|
+
"homepage": "https://github.com/pnpm/pnpm/tree/main/pnpm11/fs/graceful-fs#readme",
|
|
13
16
|
"bugs": {
|
|
14
17
|
"url": "https://github.com/pnpm/pnpm/issues"
|
|
15
18
|
},
|
|
@@ -27,8 +30,8 @@
|
|
|
27
30
|
"graceful-fs": "^4.2.11"
|
|
28
31
|
},
|
|
29
32
|
"devDependencies": {
|
|
30
|
-
"@
|
|
31
|
-
"@
|
|
33
|
+
"@pnpm/fs.graceful-fs": "1100.2.0",
|
|
34
|
+
"@types/graceful-fs": "^4.1.9"
|
|
32
35
|
},
|
|
33
36
|
"engines": {
|
|
34
37
|
"node": ">=22.13"
|