@vxrn/utils 1.27.0 → 1.27.1-1789509973946
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/createMessageSocket.cjs +115 -121
- package/dist/cjs/createMessageSocket.native.cjs +166 -0
- package/dist/cjs/createMessageSocket.native.js +152 -166
- package/dist/cjs/createMessageSocket.native.js.map +1 -1
- package/dist/cjs/detectPackageManager.cjs +76 -72
- package/dist/cjs/detectPackageManager.native.cjs +106 -0
- package/dist/cjs/detectPackageManager.native.js +82 -77
- package/dist/cjs/detectPackageManager.native.js.map +1 -1
- package/dist/cjs/exec.cjs +43 -45
- package/dist/cjs/exec.native.cjs +65 -0
- package/dist/cjs/exec.native.js +48 -49
- package/dist/cjs/exec.native.js.map +1 -1
- package/dist/cjs/index.cjs +9 -11
- package/dist/cjs/index.native.cjs +25 -0
- package/dist/cjs/index.native.js +9 -10
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/mustReplace.cjs +27 -35
- package/dist/cjs/mustReplace.native.cjs +60 -0
- package/dist/cjs/mustReplace.native.js +44 -60
- package/dist/cjs/mustReplace.native.js.map +1 -1
- package/dist/esm/createMessageSocket.mjs +103 -103
- package/dist/esm/createMessageSocket.mjs.map +1 -1
- package/dist/esm/createMessageSocket.native.js +139 -148
- package/dist/esm/createMessageSocket.native.js.map +1 -1
- package/dist/esm/detectPackageManager.mjs +65 -55
- package/dist/esm/detectPackageManager.mjs.map +1 -1
- package/dist/esm/detectPackageManager.native.js +71 -61
- package/dist/esm/detectPackageManager.native.js.map +1 -1
- package/dist/esm/exec.mjs +29 -27
- package/dist/esm/exec.mjs.map +1 -1
- package/dist/esm/exec.native.js +34 -32
- package/dist/esm/exec.native.js.map +1 -1
- package/dist/esm/index.js +11 -7
- package/dist/esm/index.mjs +11 -7
- package/dist/esm/index.native.js +11 -7
- package/dist/esm/mustReplace.mjs +15 -17
- package/dist/esm/mustReplace.mjs.map +1 -1
- package/dist/esm/mustReplace.native.js +32 -43
- package/dist/esm/mustReplace.native.js.map +1 -1
- package/package.json +4 -4
- package/types/createMessageSocket.d.ts +1 -1
- package/types/createMessageSocket.d.ts.map +1 -1
- package/types/detectPackageManager.d.ts.map +1 -1
- package/types/exec.d.ts.map +1 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/esm/index.native.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"exec.native.js","names":[],"sources":["cjs/exec.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar exec_exports = {};\n__export(exec_exports, {\n exec: () => exec,\n execPromise: () => execPromise,\n execPromiseQuiet: () => execPromiseQuiet\n});\nmodule.exports = __toCommonJS(exec_exports);\nvar import_child_process = require(\"child_process\");\nvar exec = function(cmd, options) {\n var _execSync;\n return ((_execSync = (0, import_child_process.execSync)(cmd, options)) === null || _execSync === void 0 ? void 0 : _execSync.toString()) || \"\";\n};\nvar execPromise = function(cmd, options) {\n return new Promise(function(resolve, reject) {\n var [command, ...args] = cmd.split(\" \");\n var child = (0, import_child_process.spawn)(command, args, {\n stdio: (options === null || options === void 0 ? void 0 : options.quiet) ? \"pipe\" : \"inherit\",\n shell: true,\n ...options\n });\n if (!(options === null || options === void 0 ? void 0 : options.quiet) || process.env.DEBUG) {\n var _child_stdout, _child_stderr;\n (_child_stdout = child.stdout) === null || _child_stdout === void 0 ? void 0 : _child_stdout.pipe(process.stdout);\n (_child_stderr = child.stderr) === null || _child_stderr === void 0 ? void 0 : _child_stderr.pipe(process.stderr);\n }\n child.on(\"close\", function(code) {\n if (code !== 0) {\n reject(new Error(`Command failed with exit code ${code}: ${cmd}`));\n } else {\n resolve();\n }\n });\n child.on(\"error\", function(error) {\n reject(error);\n });\n });\n};\nvar execPromiseQuiet = function(cmd, options) {\n return execPromise(cmd, {\n ...options,\n quiet: true\n });\n};\n//# sourceMappingURL=exec.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,eAAe,CAAC;AACpB,SAAS,cAAc;CACrB,YAAY;CACZ,mBAAmB;CACnB,wBAAwB;AAC1B,CAAC;AACD,OAAO,UAAU,aAAa,YAAY;AAC1C,IAA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ptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __copyProps = (to, from, except, desc) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
8
|
+
get: () => from[key],
|
|
9
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
return to;
|
|
13
13
|
};
|
|
14
14
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
16
|
-
value: true
|
|
17
|
-
}), mod);
|
|
15
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
16
|
var index_exports = {};
|
|
19
17
|
module.exports = __toCommonJS(index_exports);
|
|
20
18
|
__reExport(index_exports, require("@vxrn/debug"), module.exports);
|
|
@@ -22,4 +20,4 @@ __reExport(index_exports, require("@vxrn/resolve"), module.exports);
|
|
|
22
20
|
__reExport(index_exports, require("./createMessageSocket.cjs"), module.exports);
|
|
23
21
|
__reExport(index_exports, require("./detectPackageManager.cjs"), module.exports);
|
|
24
22
|
__reExport(index_exports, require("./exec.cjs"), module.exports);
|
|
25
|
-
__reExport(index_exports, require("./mustReplace.cjs"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./mustReplace.cjs"), module.exports);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var index_exports = {};
|
|
19
|
+
module.exports = __toCommonJS(index_exports);
|
|
20
|
+
__reExport(index_exports, require("@vxrn/debug"), module.exports);
|
|
21
|
+
__reExport(index_exports, require("@vxrn/resolve"), module.exports);
|
|
22
|
+
__reExport(index_exports, require("./createMessageSocket.native.js"), module.exports);
|
|
23
|
+
__reExport(index_exports, require("./detectPackageManager.native.js"), module.exports);
|
|
24
|
+
__reExport(index_exports, require("./exec.native.js"), module.exports);
|
|
25
|
+
__reExport(index_exports, require("./mustReplace.native.js"), module.exports);
|
package/dist/cjs/index.native.js
CHANGED
|
@@ -5,18 +5,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __copyProps = (to, from, except, desc) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
10
|
+
get: () => from[key],
|
|
11
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
15
|
};
|
|
16
16
|
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
17
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
18
|
-
value: true
|
|
19
|
-
}), mod);
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
18
|
var index_exports = {};
|
|
21
19
|
module.exports = __toCommonJS(index_exports);
|
|
22
20
|
__reExport(index_exports, require("@vxrn/debug"), module.exports);
|
|
@@ -25,4 +23,5 @@ __reExport(index_exports, require("./createMessageSocket.native.js"), module.exp
|
|
|
25
23
|
__reExport(index_exports, require("./detectPackageManager.native.js"), module.exports);
|
|
26
24
|
__reExport(index_exports, require("./exec.native.js"), module.exports);
|
|
27
25
|
__reExport(index_exports, require("./mustReplace.native.js"), module.exports);
|
|
26
|
+
|
|
28
27
|
//# sourceMappingURL=index.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.native.js","names":[],"sources":["cjs/index.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, \"default\"), secondTarget && __copyProps(secondTarget, mod, \"default\"));\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar index_exports = {};\nmodule.exports = __toCommonJS(index_exports);\n__reExport(index_exports, require(\"@vxrn/debug\"), module.exports);\n__reExport(index_exports, require(\"@vxrn/resolve\"), module.exports);\n__reExport(index_exports, require(\"./createMessageSocket\"), module.exports);\n__reExport(index_exports, require(\"./detectPackageManager\"), module.exports);\n__reExport(index_exports, require(\"./exec\"), module.exports);\n__reExport(index_exports, require(\"./mustReplace\"), module.exports);\n//# sourceMappingURL=index.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,OAAO,iBAAiB,MAAM,GAAG,MAAM,KAAK;EAAW,CAAC;CACvH;CACA,OAAO;AACT;AACA,IAAI,cAAc,QAAQ,KAAK,kBAAkB,YAAY,QAAQ,KAAK,SAAS,GAAG,gBAAgB,YAAY,cAAc,KAAK,SAAS;AAC9I,IAAI,gBAAgB,QAAQ,YAAY,UAAU,CAAC,GAAG,cAAc,EAAE,OAAO,KAAK,CAAC,GAAG,GAAG;AACzF,IAAI,gBAAgB,CAAC;AACrB,OAAO,UAAU,aAAa,aAAa;AAC3C,WAAW,eAAe,QAAQ,aAAa,GAAG,OAAO,OAAO;AAChE,WAAW,eAAe,QAAQ,eAAe,GAAG,OAAO,OAAO;AAClE,WAAW,eAAe,QAAQ,iCAAuB,GAAG,OAAO,OAAO;AAC1E,WAAW,eAAe,QAAQ,kCAAwB,GAAG,OAAO,OAAO;AAC3E,WAAW,eAAe,QAAQ,kBAAQ,GAAG,OAAO,OAAO;AAC3D,WAAW,eAAe,QAAQ,yBAAe,GAAG,OAAO,OAAO"}
|
package/dist/cjs/mustReplace.cjs
CHANGED
|
@@ -3,47 +3,39 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
3
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
5
|
var __export = (target, all) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
for (var name in all) __defProp(target, name, {
|
|
7
|
+
get: all[name],
|
|
8
|
+
enumerable: true
|
|
9
|
+
});
|
|
10
10
|
};
|
|
11
11
|
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: () => from[key],
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
19
|
};
|
|
20
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
21
|
-
value: true
|
|
22
|
-
}), mod);
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
21
|
var mustReplace_exports = {};
|
|
24
|
-
__export(mustReplace_exports, {
|
|
25
|
-
mustReplace: () => mustReplace
|
|
26
|
-
});
|
|
22
|
+
__export(mustReplace_exports, { mustReplace: () => mustReplace });
|
|
27
23
|
module.exports = __toCommonJS(mustReplace_exports);
|
|
28
24
|
var import_node_fs = require("node:fs");
|
|
29
25
|
var import_node_os = require("node:os");
|
|
30
26
|
var import_node_path = require("node:path");
|
|
31
27
|
function mustReplace(source, replacements) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
sourceOut = sourceOut.replace(find, replace);
|
|
47
|
-
}
|
|
48
|
-
return sourceOut;
|
|
49
|
-
}
|
|
28
|
+
let sourceOut = source;
|
|
29
|
+
for (const { find, replace, optional } of replacements) {
|
|
30
|
+
if (!optional) {
|
|
31
|
+
const found = find instanceof RegExp ? find.test(sourceOut) : sourceOut.includes(find);
|
|
32
|
+
if (!found) {
|
|
33
|
+
const tmpPath = (0, import_node_path.join)((0, import_node_os.tmpdir)(), `replace-error-${Math.random()}`);
|
|
34
|
+
(0, import_node_fs.writeFileSync)(tmpPath, sourceOut, "utf-8");
|
|
35
|
+
throw new Error(`Substring or pattern "${find}" not found in the string, replacing in source: ${tmpPath}.`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
sourceOut = sourceOut.replace(find, replace);
|
|
39
|
+
}
|
|
40
|
+
return sourceOut;
|
|
41
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var mustReplace_exports = {};
|
|
24
|
+
__export(mustReplace_exports, { mustReplace: () => mustReplace });
|
|
25
|
+
module.exports = __toCommonJS(mustReplace_exports);
|
|
26
|
+
var import_fs = require("fs");
|
|
27
|
+
var import_os = require("os");
|
|
28
|
+
var import_path = require("path");
|
|
29
|
+
function mustReplace(source, replacements) {
|
|
30
|
+
var sourceOut = source;
|
|
31
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
32
|
+
try {
|
|
33
|
+
for (var _iterator = replacements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
34
|
+
var { find, replace, optional } = _step.value;
|
|
35
|
+
if (!optional) {
|
|
36
|
+
var found = find instanceof RegExp ? find.test(sourceOut) : sourceOut.includes(find);
|
|
37
|
+
if (!found) {
|
|
38
|
+
var tmpPath = (0, import_path.join)((0, import_os.tmpdir)(), `replace-error-${Math.random()}`);
|
|
39
|
+
(0, import_fs.writeFileSync)(tmpPath, sourceOut, "utf-8");
|
|
40
|
+
throw new Error(`Substring or pattern "${find}" not found in the string, replacing in source: ${tmpPath}.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
sourceOut = sourceOut.replace(find, replace);
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_didIteratorError = true;
|
|
47
|
+
_iteratorError = err;
|
|
48
|
+
} finally {
|
|
49
|
+
try {
|
|
50
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
51
|
+
_iterator.return();
|
|
52
|
+
}
|
|
53
|
+
} finally {
|
|
54
|
+
if (_didIteratorError) {
|
|
55
|
+
throw _iteratorError;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return sourceOut;
|
|
60
|
+
}
|
|
@@ -5,74 +5,58 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
7
|
var __export = (target, all) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
for (var name in all) __defProp(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
12
|
};
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
21
|
};
|
|
22
|
-
var __toCommonJS = mod => __copyProps(__defProp({}, "__esModule", {
|
|
23
|
-
value: true
|
|
24
|
-
}), mod);
|
|
22
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
23
|
var mustReplace_exports = {};
|
|
26
|
-
__export(mustReplace_exports, {
|
|
27
|
-
mustReplace: () => mustReplace
|
|
28
|
-
});
|
|
24
|
+
__export(mustReplace_exports, { mustReplace: () => mustReplace });
|
|
29
25
|
module.exports = __toCommonJS(mustReplace_exports);
|
|
30
26
|
var import_fs = require("fs");
|
|
31
27
|
var import_os = require("os");
|
|
32
28
|
var import_path = require("path");
|
|
33
|
-
function _instanceof(left, right) {
|
|
34
|
-
if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
|
|
35
|
-
return !!right[Symbol.hasInstance](left);
|
|
36
|
-
} else {
|
|
37
|
-
return left instanceof right;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
29
|
function mustReplace(source, replacements) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
if (_didIteratorError) {
|
|
72
|
-
throw _iteratorError;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return sourceOut;
|
|
30
|
+
var sourceOut = source;
|
|
31
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;
|
|
32
|
+
try {
|
|
33
|
+
for (var _iterator = replacements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
34
|
+
var { find, replace, optional } = _step.value;
|
|
35
|
+
if (!optional) {
|
|
36
|
+
var found = find instanceof RegExp ? find.test(sourceOut) : sourceOut.includes(find);
|
|
37
|
+
if (!found) {
|
|
38
|
+
var tmpPath = (0, import_path.join)((0, import_os.tmpdir)(), `replace-error-${Math.random()}`);
|
|
39
|
+
(0, import_fs.writeFileSync)(tmpPath, sourceOut, "utf-8");
|
|
40
|
+
throw new Error(`Substring or pattern "${find}" not found in the string, replacing in source: ${tmpPath}.`);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
sourceOut = sourceOut.replace(find, replace);
|
|
44
|
+
}
|
|
45
|
+
} catch (err) {
|
|
46
|
+
_didIteratorError = true;
|
|
47
|
+
_iteratorError = err;
|
|
48
|
+
} finally {
|
|
49
|
+
try {
|
|
50
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
51
|
+
_iterator.return();
|
|
52
|
+
}
|
|
53
|
+
} finally {
|
|
54
|
+
if (_didIteratorError) {
|
|
55
|
+
throw _iteratorError;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return sourceOut;
|
|
77
60
|
}
|
|
61
|
+
|
|
78
62
|
//# sourceMappingURL=mustReplace.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"mustReplace.native.js","names":[],"sources":["cjs/mustReplace.native.js"],"sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\nvar mustReplace_exports = {};\n__export(mustReplace_exports, {\n mustReplace: () => mustReplace\n});\nmodule.exports = __toCommonJS(mustReplace_exports);\nvar import_fs = require(\"fs\");\nvar import_os = require(\"os\");\nvar import_path = require(\"path\");\nfunction mustReplace(source, replacements) {\n var sourceOut = source;\n var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = void 0;\n try {\n for (var _iterator = replacements[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {\n var { find, replace, optional } = _step.value;\n if (!optional) {\n var found = find instanceof RegExp ? find.test(sourceOut) : sourceOut.includes(find);\n if (!found) {\n var tmpPath = (0, import_path.join)((0, import_os.tmpdir)(), `replace-error-${Math.random()}`);\n (0, import_fs.writeFileSync)(tmpPath, sourceOut, \"utf-8\");\n throw new Error(`Substring or pattern \"${find}\" not found in the string, replacing in source: ${tmpPath}.`);\n }\n }\n sourceOut = sourceOut.replace(find, replace);\n }\n } catch (err) {\n _didIteratorError = true;\n _iteratorError = err;\n } finally {\n try {\n if (!_iteratorNormalCompletion && _iterator.return != null) {\n _iterator.return();\n }\n } finally {\n if (_didIteratorError) {\n throw _iteratorError;\n }\n }\n }\n return sourceOut;\n}\n//# sourceMappingURL=mustReplace.js.map\n"],"mappings":";;;AACA,IAAI,YAAY,OAAO;AACvB,IAAI,mBAAmB,OAAO;AAC9B,IAAI,oBAAoB,OAAO;AAC/B,IAAI,eAAe,OAAO,UAAU;AACpC,IAAI,YAAY,QAAQ,QAAQ;CAC9B,KAAK,IAAI,QAAQ,KACf,UAAU,QAAQ,MAAM;EAAE,KAAK,IAAI;EAAO,YAAY;CAAK,CAAC;AAChE;AACA,IAAI,eAAe,IAAI,MAAM,QAAQ,SAAS;CAC5C,IAAI,QAAQ,OAAO,SAAS,YAAY,OAAO,SAAS,YAAY;EAClE,KAAK,IAAI,OAAO,kBAAkB,IAAI,GACpC,IAAI,CAAC,aAAa,KAAK,IAAI,GAAG,KAAK,QAAQ,QACzC,UAAU,IAAI,KAAK;GAAE,WAAW,KAAK;GAAM,YAAY,EAAE,O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