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.
package/dist/cjs/index.d.ts
CHANGED
|
@@ -20,15 +20,19 @@ declare interface Features {
|
|
|
20
20
|
/**
|
|
21
21
|
* @default true
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
addDoubleQuotes?: boolean;
|
|
24
24
|
/**
|
|
25
25
|
* @default true
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
transformWin32Path?: boolean;
|
|
28
28
|
/**
|
|
29
29
|
* @default true
|
|
30
30
|
*/
|
|
31
|
-
|
|
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
|
-
|
|
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
|
|
429
|
-
/* harmony default export */ const _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 {
|
|
870
|
-
const { replaceRoot = true, replaceWorkspace = true, replacePnpmInner = true, replaceTmpDir = true,
|
|
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:
|
|
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 (
|
|
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
|
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -20,15 +20,19 @@ declare interface Features {
|
|
|
20
20
|
/**
|
|
21
21
|
* @default true
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
addDoubleQuotes?: boolean;
|
|
24
24
|
/**
|
|
25
25
|
* @default true
|
|
26
26
|
*/
|
|
27
|
-
|
|
27
|
+
transformWin32Path?: boolean;
|
|
28
28
|
/**
|
|
29
29
|
* @default true
|
|
30
30
|
*/
|
|
31
|
-
|
|
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
|
-
|
|
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
|
|
410
|
-
/* harmony default export */ const _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 {
|
|
845
|
-
const { replaceRoot = true, replaceWorkspace = true, replacePnpmInner = true, replaceTmpDir = true,
|
|
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:
|
|
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 (
|
|
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.
|
|
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.
|
|
23
|
-
"require": "./dist/cjs/index.
|
|
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.
|
|
28
|
-
"module": "./dist/esm/index.
|
|
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",
|