path-serializer 0.0.3 → 0.0.5-beta.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/main.cjs CHANGED
@@ -1,6 +1,216 @@
1
+ var __webpack_modules__ = ({
2
+ "./node_modules/.pnpm/upath@2.0.1/node_modules/upath/build/code/upath.js": (function (__unused_webpack_module, exports, __webpack_require__) {
3
+ /**
4
+ * upath http://github.com/anodynos/upath/
5
+ *
6
+ * A proxy to `path`, replacing `\` with `/` for all results (supports UNC paths) & new methods to normalize & join keeping leading `./` and add, change, default, trim file extensions.
7
+ * Version 2.0.1 - Compiled on 2020-11-07 16:59:47
8
+ * Repository git://github.com/anodynos/upath
9
+ * Copyright(c) 2020 Angelos Pikoulas <agelos.pikoulas@gmail.com>
10
+ * License MIT
11
+ */
12
+
13
+ // Generated by uRequire v0.7.0-beta.33 target: 'lib' template: 'nodejs'
14
+
15
+
16
+ var VERSION = '2.0.1'; // injected by urequire-rc-inject-version
17
+
18
+ var extraFn, extraFunctions, isFunction, isString, isValidExt, name, path, propName, propValue, toUnix, upath, slice = [].slice, indexOf = [].indexOf || function (item) {
19
+ for (var i = 0, l = this.length; i < l; i++) {
20
+ if (i in this && this[i] === item)
21
+ return i;
22
+ }
23
+ return -1;
24
+ }, hasProp = {}.hasOwnProperty;
25
+ path = __webpack_require__("path");
26
+ isFunction = function (val) {
27
+ return typeof val === "function";
28
+ };
29
+ isString = function (val) {
30
+ return typeof val === "string" || !!val && typeof val === "object" && Object.prototype.toString.call(val) === "[object String]";
31
+ };
32
+ upath = exports;
33
+ upath.VERSION = typeof VERSION !== "undefined" && VERSION !== null ? VERSION : "NO-VERSION";
34
+ toUnix = function (p) {
35
+ p = p.replace(/\\/g, "/");
36
+ p = p.replace(/(?<!^)\/+/g, "/");
37
+ return p;
38
+ };
39
+ for (propName in path) {
40
+ propValue = path[propName];
41
+ if (isFunction(propValue)) {
42
+ upath[propName] = function (propName) {
43
+ return function () {
44
+ var args, result;
45
+ args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
46
+ args = args.map(function (p) {
47
+ if (isString(p)) {
48
+ return toUnix(p);
49
+ } else {
50
+ return p;
51
+ }
52
+ });
53
+ result = path[propName].apply(path, args);
54
+ if (isString(result)) {
55
+ return toUnix(result);
56
+ } else {
57
+ return result;
58
+ }
59
+ };
60
+ }(propName);
61
+ } else {
62
+ upath[propName] = propValue;
63
+ }
64
+ }
65
+ upath.sep = "/";
66
+ extraFunctions = {
67
+ toUnix: toUnix,
68
+ normalizeSafe: function (p) {
69
+ var result;
70
+ p = toUnix(p);
71
+ result = upath.normalize(p);
72
+ if (p.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) {
73
+ result = "./" + result;
74
+ } else if (p.startsWith("//") && !result.startsWith("//")) {
75
+ if (p.startsWith("//./")) {
76
+ result = "//." + result;
77
+ } else {
78
+ result = "/" + result;
79
+ }
80
+ }
81
+ return result;
82
+ },
83
+ normalizeTrim: function (p) {
84
+ p = upath.normalizeSafe(p);
85
+ if (p.endsWith("/")) {
86
+ return p.slice(0, +(p.length - 2) + 1 || 9000000000);
87
+ } else {
88
+ return p;
89
+ }
90
+ },
91
+ joinSafe: function () {
92
+ var p, p0, result;
93
+ p = 1 <= arguments.length ? slice.call(arguments, 0) : [];
94
+ result = upath.join.apply(null, p);
95
+ if (p.length > 0) {
96
+ p0 = toUnix(p[0]);
97
+ if (p0.startsWith("./") && !result.startsWith("./") && !result.startsWith("..")) {
98
+ result = "./" + result;
99
+ } else if (p0.startsWith("//") && !result.startsWith("//")) {
100
+ if (p0.startsWith("//./")) {
101
+ result = "//." + result;
102
+ } else {
103
+ result = "/" + result;
104
+ }
105
+ }
106
+ }
107
+ return result;
108
+ },
109
+ addExt: function (file, ext) {
110
+ if (!ext) {
111
+ return file;
112
+ } else {
113
+ if (ext[0] !== ".") {
114
+ ext = "." + ext;
115
+ }
116
+ return file + (file.endsWith(ext) ? "" : ext);
117
+ }
118
+ },
119
+ trimExt: function (filename, ignoreExts, maxSize) {
120
+ var oldExt;
121
+ if (maxSize == null) {
122
+ maxSize = 7;
123
+ }
124
+ oldExt = upath.extname(filename);
125
+ if (isValidExt(oldExt, ignoreExts, maxSize)) {
126
+ return filename.slice(0, +(filename.length - oldExt.length - 1) + 1 || 9000000000);
127
+ } else {
128
+ return filename;
129
+ }
130
+ },
131
+ removeExt: function (filename, ext) {
132
+ if (!ext) {
133
+ return filename;
134
+ } else {
135
+ ext = ext[0] === "." ? ext : "." + ext;
136
+ if (upath.extname(filename) === ext) {
137
+ return upath.trimExt(filename, [], ext.length);
138
+ } else {
139
+ return filename;
140
+ }
141
+ }
142
+ },
143
+ changeExt: function (filename, ext, ignoreExts, maxSize) {
144
+ if (maxSize == null) {
145
+ maxSize = 7;
146
+ }
147
+ return upath.trimExt(filename, ignoreExts, maxSize) + (!ext ? "" : ext[0] === "." ? ext : "." + ext);
148
+ },
149
+ defaultExt: function (filename, ext, ignoreExts, maxSize) {
150
+ var oldExt;
151
+ if (maxSize == null) {
152
+ maxSize = 7;
153
+ }
154
+ oldExt = upath.extname(filename);
155
+ if (isValidExt(oldExt, ignoreExts, maxSize)) {
156
+ return filename;
157
+ } else {
158
+ return upath.addExt(filename, ext);
159
+ }
160
+ }
161
+ };
162
+ isValidExt = function (ext, ignoreExts, maxSize) {
163
+ if (ignoreExts == null) {
164
+ ignoreExts = [];
165
+ }
166
+ return ext && ext.length <= maxSize && indexOf.call(ignoreExts.map(function (e) {
167
+ return (e && e[0] !== "." ? "." : "") + e;
168
+ }), ext) < 0;
169
+ };
170
+ for (name in extraFunctions) {
171
+ if (!hasProp.call(extraFunctions, name))
172
+ continue;
173
+ extraFn = extraFunctions[name];
174
+ if (upath[name] !== void 0) {
175
+ throw new Error("path." + name + " already exists.");
176
+ } else {
177
+ upath[name] = extraFn;
178
+ }
179
+ }
180
+
181
+ ;
182
+
183
+ }),
184
+ "path": (function (module) {
1
185
  "use strict";
2
- // The require scope
3
- var __webpack_require__ = {};
186
+ module.exports = require("path");
187
+
188
+ }),
189
+
190
+ });
191
+ /************************************************************************/
192
+ // The module cache
193
+ var __webpack_module_cache__ = {};
194
+
195
+ // The require function
196
+ function __webpack_require__(moduleId) {
197
+
198
+ // Check if module is in cache
199
+ var cachedModule = __webpack_module_cache__[moduleId];
200
+ if (cachedModule !== undefined) {
201
+ return cachedModule.exports;
202
+ }
203
+ // Create a new module (and put it into the cache)
204
+ var module = (__webpack_module_cache__[moduleId] = {
205
+ exports: {}
206
+ });
207
+ // Execute the module function
208
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
209
+
210
+ // Return the exports of the module
211
+ return module.exports;
212
+
213
+ }
4
214
 
5
215
  /************************************************************************/
6
216
  // webpack/runtime/compat_get_default_export
@@ -48,6 +258,9 @@ __webpack_require__.r = function(exports) {
48
258
  })();
49
259
  /************************************************************************/
50
260
  var __webpack_exports__ = {};
261
+ // This entry need to be wrapped in an IIFE because it need to be in strict mode.
262
+ (() => {
263
+ "use strict";
51
264
  // ESM COMPAT FLAG
52
265
  __webpack_require__.r(__webpack_exports__);
53
266
 
@@ -770,184 +983,14 @@ function escapeRegExp(string) {
770
983
 
771
984
  /* harmony default export */ const lodash_es_escapeRegExp = (escapeRegExp);
772
985
 
773
- ;// CONCATENATED MODULE: ./src/upath.mjs
774
- // @ts-nocheck
775
- /**
776
- * upath http://github.com/anodynos/upath/
777
- *
778
- * A proxy to `path`, replacing `\` with `/` for all results (supports UNC paths) & new methods to normalize & join keeping leading `./` and add, change, default, trim file extensions.
779
- * Version 2.0.1 - Compiled on 2020-11-07 16:59:47
780
- * Repository git://github.com/anodynos/upath
781
- * Copyright(c) 2020 Angelos Pikoulas <agelos.pikoulas@gmail.com>
782
- * License MIT
783
- */ // Generated by uRequire v0.7.0-beta.33 target: 'lib' template: 'nodejs'
784
-
785
- const VERSION = '2.0.1';
786
- // injected by urequire-rc-inject-version
787
- let extraFn;
788
- let extraFunctions;
789
- let isFunction;
790
- let isString;
791
- let isValidExt;
792
- let upath_name;
793
- let upath_propName;
794
- let propValue;
795
- let toUnix;
796
- let upath;
797
- const slice = [].slice;
798
- const indexOf = [].indexOf || function(item) {
799
- for(let i = 0, l = this.length; i < l; i++){
800
- if (i in this && this[i] === item) return i;
801
- }
802
- return -1;
803
- };
804
- const hasProp = {}.hasOwnProperty;
805
- isFunction = (val)=>typeof val === 'function';
806
- isString = (val)=>typeof val === 'string' || !!val && typeof val === 'object' && Object.prototype.toString.call(val) === '[object String]';
807
- upath.VERSION = typeof VERSION !== 'undefined' && VERSION !== null ? VERSION : 'NO-VERSION';
808
- toUnix = (p)=>{
809
- p = p.replace(/\\/g, '/');
810
- p = p.replace(/(?<!^)\/+/g, '/');
811
- return p;
812
- };
813
- for(upath_propName in (external_node_path_default())){
814
- propValue = (external_node_path_default())[upath_propName];
815
- if (isFunction(propValue)) {
816
- upath[upath_propName] = ((propName)=>()=>{
817
- let args;
818
- let result;
819
- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
820
- args = args.map((p)=>{
821
- if (isString(p)) {
822
- return toUnix(p);
823
- }
824
- return p;
825
- });
826
- result = (external_node_path_default())[propName].apply((external_node_path_default()), args);
827
- if (isString(result)) {
828
- return toUnix(result);
829
- }
830
- return result;
831
- })(upath_propName);
832
- } else {
833
- upath[upath_propName] = propValue;
834
- }
835
- }
836
- upath.sep = '/';
837
- extraFunctions = {
838
- toUnix: toUnix,
839
- normalizeSafe: (p)=>{
840
- let result;
841
- p = toUnix(p);
842
- result = upath.normalize(p);
843
- if (p.startsWith('./') && !result.startsWith('./') && !result.startsWith('..')) {
844
- result = `./${result}`;
845
- } else if (p.startsWith('//') && !result.startsWith('//')) {
846
- if (p.startsWith('//./')) {
847
- result = `//.${result}`;
848
- } else {
849
- result = `/${result}`;
850
- }
851
- }
852
- return result;
853
- },
854
- normalizeTrim: (p)=>{
855
- p = upath.normalizeSafe(p);
856
- if (p.endsWith('/')) {
857
- return p.slice(0, +(p.length - 2) + 1 || 9000000000);
858
- }
859
- return p;
860
- },
861
- joinSafe: ()=>{
862
- let p;
863
- let p0;
864
- let result;
865
- p = 1 <= arguments.length ? slice.call(arguments, 0) : [];
866
- result = upath.join.apply(null, p);
867
- if (p.length > 0) {
868
- p0 = toUnix(p[0]);
869
- if (p0.startsWith('./') && !result.startsWith('./') && !result.startsWith('..')) {
870
- result = `./${result}`;
871
- } else if (p0.startsWith('//') && !result.startsWith('//')) {
872
- if (p0.startsWith('//./')) {
873
- result = `//.${result}`;
874
- } else {
875
- result = `/${result}`;
876
- }
877
- }
878
- }
879
- return result;
880
- },
881
- addExt: (file, ext)=>{
882
- if (!ext) {
883
- return file;
884
- }
885
- if (ext[0] !== '.') {
886
- ext = `.${ext}`;
887
- }
888
- return file + (file.endsWith(ext) ? '' : ext);
889
- },
890
- trimExt: (filename, ignoreExts, maxSize)=>{
891
- let oldExt;
892
- if (maxSize == null) {
893
- maxSize = 7;
894
- }
895
- oldExt = upath.extname(filename);
896
- if (isValidExt(oldExt, ignoreExts, maxSize)) {
897
- return filename.slice(0, +(filename.length - oldExt.length - 1) + 1 || 9000000000);
898
- }
899
- return filename;
900
- },
901
- removeExt: (filename, ext)=>{
902
- if (!ext) {
903
- return filename;
904
- }
905
- ext = ext[0] === '.' ? ext : `.${ext}`;
906
- if (upath.extname(filename) === ext) {
907
- return upath.trimExt(filename, [], ext.length);
908
- }
909
- return filename;
910
- },
911
- changeExt: (filename, ext, ignoreExts, maxSize)=>{
912
- if (maxSize == null) {
913
- maxSize = 7;
914
- }
915
- return upath.trimExt(filename, ignoreExts, maxSize) + (!ext ? '' : ext[0] === '.' ? ext : `.${ext}`);
916
- },
917
- defaultExt: (filename, ext, ignoreExts, maxSize)=>{
918
- let oldExt;
919
- if (maxSize == null) {
920
- maxSize = 7;
921
- }
922
- oldExt = upath.extname(filename);
923
- if (isValidExt(oldExt, ignoreExts, maxSize)) {
924
- return filename;
925
- }
926
- return upath.addExt(filename, ext);
927
- }
928
- };
929
- isValidExt = (ext, ignoreExts, maxSize)=>{
930
- if (ignoreExts == null) {
931
- ignoreExts = [];
932
- }
933
- return ext && ext.length <= maxSize && indexOf.call(ignoreExts.map((e)=>(e && e[0] !== '.' ? '.' : '') + e), ext) < 0;
934
- };
935
- for(upath_name in extraFunctions){
936
- if (!hasProp.call(extraFunctions, upath_name)) continue;
937
- extraFn = extraFunctions[upath_name];
938
- if (upath[upath_name] !== void 0) {
939
- throw new Error(`path.${upath_name} already exists.`);
940
- }
941
- upath[upath_name] = extraFn;
942
- }
943
-
944
-
986
+ // EXTERNAL MODULE: ./node_modules/.pnpm/upath@2.0.1/node_modules/upath/build/code/upath.js
987
+ var upath = __webpack_require__("./node_modules/.pnpm/upath@2.0.1/node_modules/upath/build/code/upath.js");
988
+ var upath_default = /*#__PURE__*/__webpack_require__.n(upath);
945
989
  ;// CONCATENATED MODULE: ./src/utils.ts
946
990
 
947
991
 
948
992
 
949
993
 
950
- // @ts-ignore
951
994
 
952
995
  const isPathString = (test)=>external_node_path_default().posix.basename(test) !== test || external_node_path_default().win32.basename(test) !== test;
953
996
  function getRealTemporaryDirectory() {
@@ -959,7 +1002,7 @@ function getRealTemporaryDirectory() {
959
1002
  return ret;
960
1003
  }
961
1004
  const normalizeToPosixPath = (p)=>{
962
- return upath.normalizeSafe(external_node_path_default().normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
1005
+ return upath_default().normalizeSafe(external_node_path_default().normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
963
1006
  };
964
1007
  /**
965
1008
  * Compile path string to RegExp.
@@ -1001,7 +1044,7 @@ function applyMatcherReplacement(matchers, str, options = {}) {
1001
1044
  const createDefaultPathMatchers = ()=>{
1002
1045
  const ret = [
1003
1046
  {
1004
- match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
1047
+ match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/g,
1005
1048
  mark: 'pnpmInner'
1006
1049
  }
1007
1050
  ];
@@ -1021,10 +1064,20 @@ const createDefaultPathMatchers = ()=>{
1021
1064
  return ret;
1022
1065
  };
1023
1066
 
1067
+ ;// CONCATENATED MODULE: ./src/transformCodeToPosixPath.ts
1068
+
1069
+ function transformCodeToPosixPath(code) {
1070
+ return code.replace(/([a-zA-Z]:\\)([-\u4e00-\u9fa5\w\s.()~!@#$%^&()\[\]{}+=]+\\)*/g, (match)=>{
1071
+ return normalizeToPosixPath(match);
1072
+ });
1073
+ }
1074
+
1075
+
1024
1076
  ;// CONCATENATED MODULE: ./src/createSnapshotSerializer.ts
1025
1077
 
1026
1078
 
1027
1079
 
1080
+
1028
1081
  function createSnapshotSerializer(options) {
1029
1082
  const { cwd = process.cwd(), workspace = process.cwd(), replace: customMatchers = [] } = options || {};
1030
1083
  const pathMatchers = [
@@ -1049,7 +1102,7 @@ function createSnapshotSerializer(options) {
1049
1102
  // match path-format string
1050
1103
  test: (val)=>typeof val === 'string' && isPathString(val),
1051
1104
  print: (val)=>{
1052
- const normalized = normalizeToPosixPath(val);
1105
+ const normalized = transformCodeToPosixPath(val);
1053
1106
  const replaced = applyMatcherReplacement(pathMatchers, normalized).replace(/"/g, '\\"');
1054
1107
  return `"${replaced}"`;
1055
1108
  }
@@ -1059,6 +1112,8 @@ function createSnapshotSerializer(options) {
1059
1112
  ;// CONCATENATED MODULE: ./src/index.ts
1060
1113
 
1061
1114
 
1115
+ })();
1116
+
1062
1117
  var __webpack_export_target__ = exports;
1063
1118
  for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
1064
1119
  if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', { value: true });