path-serializer 0.0.2 → 0.0.3

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,216 +1,6 @@
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) {
185
1
  "use strict";
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
- }
2
+ // The require scope
3
+ var __webpack_require__ = {};
214
4
 
215
5
  /************************************************************************/
216
6
  // webpack/runtime/compat_get_default_export
@@ -258,9 +48,6 @@ __webpack_require__.r = function(exports) {
258
48
  })();
259
49
  /************************************************************************/
260
50
  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";
264
51
  // ESM COMPAT FLAG
265
52
  __webpack_require__.r(__webpack_exports__);
266
53
 
@@ -269,9 +56,6 @@ __webpack_require__.d(__webpack_exports__, {
269
56
  createSnapshotSerializer: () => (/* reexport */ createSnapshotSerializer)
270
57
  });
271
58
 
272
- ;// CONCATENATED MODULE: external "node:os"
273
- var external_node_os_namespaceObject = require("node:os");
274
- var external_node_os_default = /*#__PURE__*/__webpack_require__.n(external_node_os_namespaceObject);
275
59
  ;// CONCATENATED MODULE: ./node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayReduce.js
276
60
  /**
277
61
  * A specialized version of `_.reduce` for arrays without support for
@@ -946,6 +730,9 @@ var snakeCase_snakeCase = _createCompounder(function(result, word, index) {
946
730
  ;// CONCATENATED MODULE: external "node:fs"
947
731
  var external_node_fs_namespaceObject = require("node:fs");
948
732
  var external_node_fs_default = /*#__PURE__*/__webpack_require__.n(external_node_fs_namespaceObject);
733
+ ;// CONCATENATED MODULE: external "node:os"
734
+ var external_node_os_namespaceObject = require("node:os");
735
+ var external_node_os_default = /*#__PURE__*/__webpack_require__.n(external_node_os_namespaceObject);
949
736
  ;// CONCATENATED MODULE: external "node:path"
950
737
  var external_node_path_namespaceObject = require("node:path");
951
738
  var external_node_path_default = /*#__PURE__*/__webpack_require__.n(external_node_path_namespaceObject);
@@ -983,17 +770,187 @@ function escapeRegExp(string) {
983
770
 
984
771
  /* harmony default export */ const lodash_es_escapeRegExp = (escapeRegExp);
985
772
 
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);
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
+
989
945
  ;// CONCATENATED MODULE: ./src/utils.ts
990
946
 
991
947
 
992
948
 
993
949
 
950
+ // @ts-ignore
994
951
 
995
952
  const isPathString = (test)=>external_node_path_default().posix.basename(test) !== test || external_node_path_default().win32.basename(test) !== test;
996
- function utils_getRealTemporaryDirectory() {
953
+ function getRealTemporaryDirectory() {
997
954
  let ret = null;
998
955
  try {
999
956
  ret = external_node_os_default().tmpdir();
@@ -1001,7 +958,9 @@ function utils_getRealTemporaryDirectory() {
1001
958
  } catch {}
1002
959
  return ret;
1003
960
  }
1004
- const normalizeToPosixPath = (p)=>upath_default().normalizeSafe(external_node_path_default().normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
961
+ const normalizeToPosixPath = (p)=>{
962
+ return upath.normalizeSafe(external_node_path_default().normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
963
+ };
1005
964
  /**
1006
965
  * Compile path string to RegExp.
1007
966
  * @note Only support posix path.
@@ -1019,7 +978,6 @@ function splitPathString(str) {
1019
978
  ;// CONCATENATED MODULE: ./src/applyMatcherReplacement.ts
1020
979
 
1021
980
 
1022
-
1023
981
  function applyPathMatcher(matcher, str, options = {}) {
1024
982
  const regex = compilePathMatcherRegExp(matcher.match);
1025
983
  const replacer = (substring, ...args)=>{
@@ -1036,40 +994,18 @@ function applyMatcherReplacement(matchers, str, options = {}) {
1036
994
  return applyPathMatcher(matcher, ret, options);
1037
995
  }, str);
1038
996
  }
1039
- const createDefaultPathMatchers = ()=>{
1040
- const ret = [
1041
- {
1042
- match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
1043
- mark: 'pnpmInner'
1044
- }
1045
- ];
1046
- const tmpdir = getRealTemporaryDirectory();
1047
- tmpdir && ret.push({
1048
- match: tmpdir,
1049
- mark: 'temp'
1050
- });
1051
- ret.push({
1052
- match: os.tmpdir(),
1053
- mark: 'temp'
1054
- });
1055
- ret.push({
1056
- match: os.homedir(),
1057
- mark: 'home'
1058
- });
1059
- return ret;
1060
- };
1061
997
 
1062
998
  ;// CONCATENATED MODULE: ./src/createDefaultPathMatchers.ts
1063
999
 
1064
1000
 
1065
- const createDefaultPathMatchers_createDefaultPathMatchers = ()=>{
1001
+ const createDefaultPathMatchers = ()=>{
1066
1002
  const ret = [
1067
1003
  {
1068
1004
  match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
1069
1005
  mark: 'pnpmInner'
1070
1006
  }
1071
1007
  ];
1072
- const tmpdir = utils_getRealTemporaryDirectory();
1008
+ const tmpdir = getRealTemporaryDirectory();
1073
1009
  tmpdir && ret.push({
1074
1010
  match: tmpdir,
1075
1011
  mark: 'temp'
@@ -1101,7 +1037,7 @@ function createSnapshotSerializer(options) {
1101
1037
  match: workspace
1102
1038
  },
1103
1039
  ...customMatchers,
1104
- ...createDefaultPathMatchers_createDefaultPathMatchers()
1040
+ ...createDefaultPathMatchers()
1105
1041
  ];
1106
1042
  for (const matcher of pathMatchers){
1107
1043
  if (typeof matcher.match === 'string') {
@@ -1123,8 +1059,6 @@ function createSnapshotSerializer(options) {
1123
1059
  ;// CONCATENATED MODULE: ./src/index.ts
1124
1060
 
1125
1061
 
1126
- })();
1127
-
1128
1062
  var __webpack_export_target__ = exports;
1129
1063
  for(var i in __webpack_exports__) __webpack_export_target__[i] = __webpack_exports__[i];
1130
1064
  if(__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', { value: true });