@hyperframes/core 0.9.45 → 0.9.46

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.
@@ -6,6 +6,7 @@ export declare function atomicTempPath(filePath: string): string;
6
6
  export declare function isAtomicTempPath(path: string): boolean;
7
7
  /** Replace a file only after the complete sibling temp file is written. No mode: the default one. */
8
8
  export declare function replaceFileAtomically(filePath: string, content: string | Uint8Array, mode?: number, operations?: SiblingFileSystem & Pick<typeof fs, "renameSync">): void;
9
+ export declare function refuseReadOnly(filePath: string): void;
9
10
  /** Create a file that must not exist yet (EEXIST otherwise); readers never see it empty or partial. */
10
11
  export declare function createFileAtomically(filePath: string, content: string | Uint8Array, operations?: DirectFileSystem & Pick<typeof fs, "linkSync">): void;
11
12
  /** The file a write to `filePath` lands on: folder links and file links followed as the system does. */
@@ -33,9 +33,19 @@ function traceWrite(filePath, content) {
33
33
  /** Replace a file only after the complete sibling temp file is written. No mode: the default one. */
34
34
  export function replaceFileAtomically(filePath, content, mode, operations = fs) {
35
35
  traceWrite(filePath, content);
36
+ refuseReadOnly(filePath);
36
37
  // Node fs.rename uses libuv uv_fs_rename; win32 calls MoveFileExW with MOVEFILE_REPLACE_EXISTING.
37
38
  publishSibling(filePath, content, mode, operations, (tempPath) => renameWithRetry(tempPath, filePath, { rename: operations.renameSync }));
38
39
  }
40
+ export function refuseReadOnly(filePath) {
41
+ try {
42
+ fs.accessSync(filePath, fs.constants.W_OK);
43
+ }
44
+ catch (error) {
45
+ if (errorCode(error) !== "ENOENT")
46
+ throw error;
47
+ }
48
+ }
39
49
  /** Create a file that must not exist yet (EEXIST otherwise); readers never see it empty or partial. */
40
50
  export function createFileAtomically(filePath, content, operations = fs) {
41
51
  publishSibling(filePath, content, undefined, operations, (tempPath) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/core",
3
- "version": "0.9.45",
3
+ "version": "0.9.46",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -449,9 +449,9 @@
449
449
  "linkedom": "^0.18.12",
450
450
  "postcss": "^8.5.8",
451
451
  "wawoff2": "^2.0.1",
452
- "@hyperframes/lint": "0.9.45",
453
- "@hyperframes/parsers": "0.9.45",
454
- "@hyperframes/studio-server": "0.9.45"
452
+ "@hyperframes/studio-server": "0.9.46",
453
+ "@hyperframes/lint": "0.9.46",
454
+ "@hyperframes/parsers": "0.9.46"
455
455
  },
456
456
  "devDependencies": {
457
457
  "@fontsource/archivo-black": "^5.2.8",