path-serializer 0.1.4 → 0.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.
@@ -20,15 +20,19 @@ declare interface Features {
20
20
  /**
21
21
  * @default true
22
22
  */
23
- ansiDoubleQuotes?: boolean;
23
+ addDoubleQuotes?: boolean;
24
24
  /**
25
25
  * @default true
26
26
  */
27
- addDoubleQuotes?: boolean;
27
+ transformWin32Path?: boolean;
28
28
  /**
29
29
  * @default true
30
30
  */
31
- transformWin32Path?: boolean;
31
+ escapeDoubleQuotes?: boolean;
32
+ /**
33
+ * @default true
34
+ */
35
+ escapeEOL?: boolean;
32
36
  }
33
37
 
34
38
  declare interface PathMatcher {
@@ -44,9 +48,10 @@ declare interface SnapshotSerializer {
44
48
  }
45
49
 
46
50
  declare interface SnapshotSerializerOptions {
47
- cwd?: string;
51
+ root?: string;
48
52
  workspace?: string;
49
53
  replace?: PathMatcher[];
54
+ replacePost?: PathMatcher[];
50
55
  features?: Features;
51
56
  }
52
57
 
@@ -425,8 +425,8 @@ function __webpack_require__(moduleId) {
425
425
  /** Detect free variable `global` from Node.js. */ var freeGlobal = 'object' == typeof global && global && global.Object === Object && global;
426
426
  /* harmony default export */ const _freeGlobal = freeGlobal;
427
427
  /** Detect free variable `self`. */ var freeSelf = 'object' == typeof self && self && self.Object === Object && self;
428
- /** Used as a reference to the global object. */ var root = _freeGlobal || freeSelf || Function('return this')();
429
- /* harmony default export */ const _root = root;
428
+ /** Used as a reference to the global object. */ var _root_root = _freeGlobal || freeSelf || Function('return this')();
429
+ /* harmony default export */ const _root = _root_root;
430
430
  /** Built-in value references. */ var Symbol1 = _root.Symbol;
431
431
  /* harmony default export */ const _Symbol = Symbol1;
432
432
  /**
@@ -866,21 +866,22 @@ function __webpack_require__(moduleId) {
866
866
  /(?<![a-zA-Z])([a-zA-Z]:[\\/])([-\u4e00-\u9fa5\w\s.()~!@#$%^&()\[\]{}+=]+[\\/])*/g, (match, _diskName)=>normalizeToPosixPath(match));
867
867
  }
868
868
  function createSnapshotSerializer(options) {
869
- const { cwd = process.cwd(), workspace = process.cwd(), replace: customMatchers = [], features = {} } = options || {};
870
- const { replaceRoot = true, replaceWorkspace = true, replacePnpmInner = true, replaceTmpDir = true, ansiDoubleQuotes = true, addDoubleQuotes = true, transformWin32Path = true } = features;
869
+ const { root = process.cwd(), workspace = process.cwd(), replace: customMatchers = [], replacePost: customPostMatchers = [], features = {} } = options || {};
870
+ const { replaceRoot = true, replaceWorkspace = true, replacePnpmInner = true, replaceTmpDir = true, addDoubleQuotes = true, transformWin32Path = true, escapeDoubleQuotes = true, escapeEOL = true } = features;
871
871
  function createPathMatchers() {
872
872
  const pathMatchers = [];
873
+ pathMatchers.push(...customMatchers);
873
874
  if (replaceRoot) pathMatchers.push({
874
875
  mark: 'root',
875
- match: cwd
876
+ match: root
876
877
  });
877
878
  if (replaceWorkspace) pathMatchers.push({
878
879
  mark: 'workspace',
879
880
  match: workspace
880
881
  });
881
882
  if (replacePnpmInner) pathMatchers.push(...createPnpmInnerMatchers());
882
- pathMatchers.push(...customMatchers);
883
883
  if (replaceTmpDir) pathMatchers.push(...createTmpDirMatchers());
884
+ pathMatchers.push(...customPostMatchers);
884
885
  return pathMatchers;
885
886
  }
886
887
  const pathMatchers = createPathMatchers();
@@ -894,7 +895,8 @@ function __webpack_require__(moduleId) {
894
895
  let replaced = val;
895
896
  if (transformWin32Path) replaced = transformCodeToPosixPath(replaced);
896
897
  replaced = applyMatcherReplacement(pathMatchers, replaced);
897
- if (ansiDoubleQuotes) replaced = replaced.replace(/"/g, '\\"');
898
+ if (escapeDoubleQuotes) replaced = replaced.replace(/"/g, '\\"');
899
+ if (escapeEOL) replaced = replaced.replace(/\\r\\n/g, '\n');
898
900
  if (addDoubleQuotes) replaced = `"${replaced}"`;
899
901
  return replaced;
900
902
  }
@@ -20,15 +20,19 @@ declare interface Features {
20
20
  /**
21
21
  * @default true
22
22
  */
23
- ansiDoubleQuotes?: boolean;
23
+ addDoubleQuotes?: boolean;
24
24
  /**
25
25
  * @default true
26
26
  */
27
- addDoubleQuotes?: boolean;
27
+ transformWin32Path?: boolean;
28
28
  /**
29
29
  * @default true
30
30
  */
31
- transformWin32Path?: boolean;
31
+ escapeDoubleQuotes?: boolean;
32
+ /**
33
+ * @default true
34
+ */
35
+ escapeEOL?: boolean;
32
36
  }
33
37
 
34
38
  declare interface PathMatcher {
@@ -44,9 +48,10 @@ declare interface SnapshotSerializer {
44
48
  }
45
49
 
46
50
  declare interface SnapshotSerializerOptions {
47
- cwd?: string;
51
+ root?: string;
48
52
  workspace?: string;
49
53
  replace?: PathMatcher[];
54
+ replacePost?: PathMatcher[];
50
55
  features?: Features;
51
56
  }
52
57
 
@@ -406,8 +406,8 @@ function __webpack_require__(moduleId) {
406
406
  /** Detect free variable `global` from Node.js. */ var freeGlobal = 'object' == typeof global && global && global.Object === Object && global;
407
407
  /* harmony default export */ const _freeGlobal = freeGlobal;
408
408
  /** Detect free variable `self`. */ var freeSelf = 'object' == typeof self && self && self.Object === Object && self;
409
- /** Used as a reference to the global object. */ var root = _freeGlobal || freeSelf || Function('return this')();
410
- /* harmony default export */ const _root = root;
409
+ /** Used as a reference to the global object. */ var _root_root = _freeGlobal || freeSelf || Function('return this')();
410
+ /* harmony default export */ const _root = _root_root;
411
411
  /** Built-in value references. */ var Symbol = _root.Symbol;
412
412
  /* harmony default export */ const _Symbol = Symbol;
413
413
  /**
@@ -841,21 +841,22 @@ function transformCodeToPosixPath(code) {
841
841
  /(?<![a-zA-Z])([a-zA-Z]:[\\/])([-\u4e00-\u9fa5\w\s.()~!@#$%^&()\[\]{}+=]+[\\/])*/g, (match, _diskName)=>normalizeToPosixPath(match));
842
842
  }
843
843
  function createSnapshotSerializer(options) {
844
- const { cwd = process.cwd(), workspace = process.cwd(), replace: customMatchers = [], features = {} } = options || {};
845
- const { replaceRoot = true, replaceWorkspace = true, replacePnpmInner = true, replaceTmpDir = true, ansiDoubleQuotes = true, addDoubleQuotes = true, transformWin32Path = true } = features;
844
+ const { root = process.cwd(), workspace = process.cwd(), replace: customMatchers = [], replacePost: customPostMatchers = [], features = {} } = options || {};
845
+ const { replaceRoot = true, replaceWorkspace = true, replacePnpmInner = true, replaceTmpDir = true, addDoubleQuotes = true, transformWin32Path = true, escapeDoubleQuotes = true, escapeEOL = true } = features;
846
846
  function createPathMatchers() {
847
847
  const pathMatchers = [];
848
+ pathMatchers.push(...customMatchers);
848
849
  if (replaceRoot) pathMatchers.push({
849
850
  mark: 'root',
850
- match: cwd
851
+ match: root
851
852
  });
852
853
  if (replaceWorkspace) pathMatchers.push({
853
854
  mark: 'workspace',
854
855
  match: workspace
855
856
  });
856
857
  if (replacePnpmInner) pathMatchers.push(...createPnpmInnerMatchers());
857
- pathMatchers.push(...customMatchers);
858
858
  if (replaceTmpDir) pathMatchers.push(...createTmpDirMatchers());
859
+ pathMatchers.push(...customPostMatchers);
859
860
  return pathMatchers;
860
861
  }
861
862
  const pathMatchers = createPathMatchers();
@@ -869,7 +870,8 @@ function createSnapshotSerializer(options) {
869
870
  let replaced = val;
870
871
  if (transformWin32Path) replaced = transformCodeToPosixPath(replaced);
871
872
  replaced = applyMatcherReplacement(pathMatchers, replaced);
872
- if (ansiDoubleQuotes) replaced = replaced.replace(/"/g, '\\"');
873
+ if (escapeDoubleQuotes) replaced = replaced.replace(/"/g, '\\"');
874
+ if (escapeEOL) replaced = replaced.replace(/\\r\\n/g, '\n');
873
875
  if (addDoubleQuotes) replaced = `"${replaced}"`;
874
876
  return replaced;
875
877
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "path-serializer",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "description": "path-serializer",
5
5
  "keywords": [
6
6
  "snapshot",
@@ -9,7 +9,6 @@
9
9
  "ci",
10
10
  "test"
11
11
  ],
12
- "type": "module",
13
12
  "repository": {
14
13
  "type": "git",
15
14
  "url": "https://github.com/rspack-contrib/path-serializer.git"
@@ -19,13 +18,13 @@
19
18
  "exports": {
20
19
  ".": {
21
20
  "types": "./dist/esm/index.d.ts",
22
- "import": "./dist/esm/index.js",
23
- "require": "./dist/cjs/index.cjs"
21
+ "import": "./dist/esm/index.mjs",
22
+ "require": "./dist/cjs/index.js"
24
23
  },
25
24
  "./package.json": "./package.json"
26
25
  },
27
- "main": "./dist/cjs/index.cjs",
28
- "module": "./dist/esm/index.js",
26
+ "main": "./dist/cjs/index.js",
27
+ "module": "./dist/esm/index.mjs",
29
28
  "types": "./dist/esm/index.d.ts",
30
29
  "files": [
31
30
  "dist",