@jsenv/snapshot 2.9.5 → 2.9.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jsenv/snapshot",
3
- "version": "2.9.5",
3
+ "version": "2.9.7",
4
4
  "description": "Snapshot testing",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -36,7 +36,8 @@
36
36
  "@jsenv/assert": "4.4.0",
37
37
  "@jsenv/ast": "6.2.16",
38
38
  "@jsenv/exception": "1.1.1",
39
- "@jsenv/filesystem": "4.10.0",
39
+ "@jsenv/humanize": "1.2.8",
40
+ "@jsenv/filesystem": "4.10.1",
40
41
  "@jsenv/terminal-recorder": "1.4.4",
41
42
  "@jsenv/urls": "2.5.2",
42
43
  "@jsenv/utils": "2.1.2",
@@ -68,6 +68,15 @@ export const replaceFluctuatingValues = (
68
68
  // );
69
69
  return string;
70
70
  };
71
+ // const replaceUnicodeFallbacks = (string) => {
72
+ // string = string.replaceAll(">", "❯");
73
+ // string = string.replaceAll("√", "✔");
74
+ // string = string.replaceAll("×", "✖");
75
+ // string = string.replaceAll("♦", "◆");
76
+ // string = string.replaceAll("i", "ℹ");
77
+ // // string = string.replaceAll("‼", "⚠");
78
+ // return string;
79
+ // };
71
80
  const replaceThings = (string, { shouldReplaceDurations } = {}) => {
72
81
  if (stringType === "filesystem") {
73
82
  return replaceFilesystemWellKnownValues(string);
@@ -82,6 +91,7 @@ export const replaceFluctuatingValues = (
82
91
  if (shouldReplaceDurations !== false) {
83
92
  string = replaceDurations(string);
84
93
  }
94
+ // string = replaceUnicodeFallbacks(string);
85
95
  string = replaceSizes(string);
86
96
  return string;
87
97
  };
@@ -1,4 +1,5 @@
1
1
  import { parseFunction } from "@jsenv/assert/src/utils/function_parser.js";
2
+ import { ANSI, UNICODE } from "@jsenv/humanize";
2
3
  import { createReplaceFilesystemWellKnownValues } from "../filesystem_well_known_values.js";
3
4
  import { filesystemSideEffects } from "./filesystem/filesystem_side_effects.js";
4
5
  import { logSideEffects } from "./log/log_side_effects.js";
@@ -37,6 +38,14 @@ export const createCaptureSideEffects = ({
37
38
  };
38
39
  let functionExecutingCount = 0;
39
40
  const capture = (fn, { callSite, baseDirectory } = {}) => {
41
+ const unicodeSupported = UNICODE.supported;
42
+ const ansiSupported = ANSI.supported;
43
+ // this is fragile because if the copy of humanize we have
44
+ // is not the same (different version)
45
+ // we won't be able to force support
46
+ // good enough for now
47
+ UNICODE.supported = true;
48
+ ANSI.supported = true;
40
49
  if (baseDirectory !== undefined && filesystemSideEffectsDetector) {
41
50
  filesystemSideEffectsDetector.setBaseDirectory(baseDirectory);
42
51
  }
@@ -265,6 +274,8 @@ export const createCaptureSideEffects = ({
265
274
  };
266
275
  const onFinally = () => {
267
276
  delete process.env.CAPTURING_SIDE_EFFECTS;
277
+ UNICODE.supported = unicodeSupported;
278
+ ANSI.supported = ansiSupported;
268
279
  functionExecutingCount--;
269
280
  for (const finallyCallback of finallyCallbackSet) {
270
281
  finallyCallback(sideEffects);
@@ -1,4 +1,9 @@
1
- import { setUrlBasename, urlIsInsideOf, urlToRelativeUrl } from "@jsenv/urls";
1
+ import {
2
+ setUrlBasename,
3
+ startsWithWindowsDriveLetter,
4
+ urlIsInsideOf,
5
+ urlToRelativeUrl,
6
+ } from "@jsenv/urls";
2
7
  import { CONTENT_TYPE } from "@jsenv/utils/src/content_type/content_type.js";
3
8
  import { pathToFileURL } from "node:url";
4
9
  import { createWellKnown } from "../../filesystem_well_known_values.js";
@@ -124,7 +129,15 @@ export const filesystemSideEffects = (
124
129
  // collapse them if they have a shared ancestor
125
130
  groupFileSideEffectsPerDirectory(sideEffects, {
126
131
  createWriteFileGroupSideEffect: (fileSideEffectArray, commonPath) => {
127
- let commonUrl = pathToFileURL(commonPath);
132
+ let commonUrl;
133
+ if (
134
+ process.platform === "win32" &&
135
+ startsWithWindowsDriveLetter(commonPath.slice(1))
136
+ ) {
137
+ commonUrl = pathToFileURL(commonPath.slice("/C:".length));
138
+ } else {
139
+ commonUrl = pathToFileURL(commonPath);
140
+ }
128
141
  let commonDirectoryUrl;
129
142
  if (commonUrl.href.endsWith("/")) {
130
143
  commonDirectoryUrl = commonUrl;