@ac-kit/core 0.1.0 → 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.
Files changed (126) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/dist/big-int/is-safe-number.d.ts +20 -0
  3. package/dist/big-int/is-safe-number.d.ts.map +1 -0
  4. package/dist/big-int/is-safe-number.js +24 -0
  5. package/dist/big-int/is-safe-number.js.map +1 -0
  6. package/dist/guards/has-object-prototype.d.ts +27 -0
  7. package/dist/guards/has-object-prototype.d.ts.map +1 -0
  8. package/dist/guards/has-object-prototype.js +30 -0
  9. package/dist/guards/has-object-prototype.js.map +1 -0
  10. package/dist/guards/is-object.d.ts +28 -2
  11. package/dist/guards/is-object.d.ts.map +1 -1
  12. package/dist/guards/is-object.js +28 -2
  13. package/dist/guards/is-object.js.map +1 -1
  14. package/dist/guards/is-pojo.d.ts +27 -2
  15. package/dist/guards/is-pojo.d.ts.map +1 -1
  16. package/dist/guards/is-pojo.js +27 -2
  17. package/dist/guards/is-pojo.js.map +1 -1
  18. package/dist/index.d.ts +11 -13
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +11 -13
  21. package/dist/index.js.map +1 -1
  22. package/dist/json/replacers/big-int.d.ts.map +1 -1
  23. package/dist/json/replacers/big-int.js +2 -5
  24. package/dist/json/replacers/big-int.js.map +1 -1
  25. package/dist/number/parse-number-or-big-int.d.ts +30 -0
  26. package/dist/number/parse-number-or-big-int.d.ts.map +1 -0
  27. package/dist/number/parse-number-or-big-int.js +44 -0
  28. package/dist/number/parse-number-or-big-int.js.map +1 -0
  29. package/dist/object/defaults.d.ts.map +1 -1
  30. package/dist/object/defaults.js +11 -4
  31. package/dist/object/defaults.js.map +1 -1
  32. package/dist/object/get-at-path.d.ts +5 -0
  33. package/dist/object/get-at-path.d.ts.map +1 -1
  34. package/dist/object/get-at-path.js +5 -0
  35. package/dist/object/get-at-path.js.map +1 -1
  36. package/dist/object/is-unsafe-record-key.d.ts +26 -0
  37. package/dist/object/is-unsafe-record-key.d.ts.map +1 -0
  38. package/dist/object/is-unsafe-record-key.js +28 -0
  39. package/dist/object/is-unsafe-record-key.js.map +1 -0
  40. package/dist/object/merge-inplace.d.ts.map +1 -1
  41. package/dist/object/merge-inplace.js +4 -2
  42. package/dist/object/merge-inplace.js.map +1 -1
  43. package/dist/object/merge.d.ts.map +1 -1
  44. package/dist/object/merge.js +4 -2
  45. package/dist/object/merge.js.map +1 -1
  46. package/dist/object/null-if-empty.d.ts +12 -0
  47. package/dist/object/null-if-empty.d.ts.map +1 -0
  48. package/dist/object/null-if-empty.js +17 -0
  49. package/dist/object/null-if-empty.js.map +1 -0
  50. package/dist/object/set-at-path.d.ts +5 -0
  51. package/dist/object/set-at-path.d.ts.map +1 -1
  52. package/dist/object/set-at-path.js +10 -3
  53. package/dist/object/set-at-path.js.map +1 -1
  54. package/dist/object/set-record-entry.d.ts +32 -0
  55. package/dist/object/set-record-entry.d.ts.map +1 -0
  56. package/dist/object/set-record-entry.js +43 -0
  57. package/dist/object/set-record-entry.js.map +1 -0
  58. package/dist/object/traverse.js +3 -3
  59. package/dist/object/traverse.js.map +1 -1
  60. package/dist/system/fs/escape-posix-path.d.ts.map +1 -0
  61. package/dist/system/fs/escape-posix-path.js.map +1 -0
  62. package/dist/system/fs/escape-win32-path.d.ts.map +1 -0
  63. package/dist/system/fs/escape-win32-path.js.map +1 -0
  64. package/dist/system/net/ephemeral-port.d.ts.map +1 -0
  65. package/dist/system/net/ephemeral-port.js.map +1 -0
  66. package/dist/system/net/inet-address.d.ts.map +1 -0
  67. package/dist/system/net/inet-address.js.map +1 -0
  68. package/dist/system/net/inet-endpoint.d.ts.map +1 -0
  69. package/dist/system/net/inet-endpoint.js.map +1 -0
  70. package/package.json +2 -2
  71. package/dist/guards/is-plain-object.d.ts +0 -8
  72. package/dist/guards/is-plain-object.d.ts.map +0 -1
  73. package/dist/guards/is-plain-object.js +0 -11
  74. package/dist/guards/is-plain-object.js.map +0 -1
  75. package/dist/net/ephemeral-port.d.ts.map +0 -1
  76. package/dist/net/ephemeral-port.js.map +0 -1
  77. package/dist/net/inet-address.d.ts.map +0 -1
  78. package/dist/net/inet-address.js.map +0 -1
  79. package/dist/net/inet-endpoint.d.ts.map +0 -1
  80. package/dist/net/inet-endpoint.js.map +0 -1
  81. package/dist/shell/fs/escape-posix-path.d.ts.map +0 -1
  82. package/dist/shell/fs/escape-posix-path.js.map +0 -1
  83. package/dist/shell/fs/escape-win32-path.d.ts.map +0 -1
  84. package/dist/shell/fs/escape-win32-path.js.map +0 -1
  85. package/dist/shell/process/parse-env-variable.d.ts +0 -43
  86. package/dist/shell/process/parse-env-variable.d.ts.map +0 -1
  87. package/dist/shell/process/parse-env-variable.js +0 -109
  88. package/dist/shell/process/parse-env-variable.js.map +0 -1
  89. package/dist/shell/process/stringify-env-variable.d.ts +0 -50
  90. package/dist/shell/process/stringify-env-variable.d.ts.map +0 -1
  91. package/dist/shell/process/stringify-env-variable.js +0 -86
  92. package/dist/shell/process/stringify-env-variable.js.map +0 -1
  93. package/dist/shell/process/types.d.ts +0 -7
  94. package/dist/shell/process/types.d.ts.map +0 -1
  95. package/dist/shell/process/types.js +0 -2
  96. package/dist/shell/process/types.js.map +0 -1
  97. package/dist/shell/shell/escape-posix-sh-command-arg.d.ts +0 -20
  98. package/dist/shell/shell/escape-posix-sh-command-arg.d.ts.map +0 -1
  99. package/dist/shell/shell/escape-posix-sh-command-arg.js +0 -26
  100. package/dist/shell/shell/escape-posix-sh-command-arg.js.map +0 -1
  101. package/dist/shell/shell/escape-posix-sh-command.d.ts +0 -19
  102. package/dist/shell/shell/escape-posix-sh-command.d.ts.map +0 -1
  103. package/dist/shell/shell/escape-posix-sh-command.js +0 -55
  104. package/dist/shell/shell/escape-posix-sh-command.js.map +0 -1
  105. package/dist/shell/shell/escape-posix-sh-sqe.d.ts +0 -13
  106. package/dist/shell/shell/escape-posix-sh-sqe.d.ts.map +0 -1
  107. package/dist/shell/shell/escape-posix-sh-sqe.js +0 -15
  108. package/dist/shell/shell/escape-posix-sh-sqe.js.map +0 -1
  109. package/dist/shell/shell/escape-win32-cmd-command-arg.d.ts +0 -20
  110. package/dist/shell/shell/escape-win32-cmd-command-arg.d.ts.map +0 -1
  111. package/dist/shell/shell/escape-win32-cmd-command-arg.js +0 -29
  112. package/dist/shell/shell/escape-win32-cmd-command-arg.js.map +0 -1
  113. package/dist/shell/shell/escape-win32-cmd-command.d.ts +0 -18
  114. package/dist/shell/shell/escape-win32-cmd-command.d.ts.map +0 -1
  115. package/dist/shell/shell/escape-win32-cmd-command.js +0 -20
  116. package/dist/shell/shell/escape-win32-cmd-command.js.map +0 -1
  117. /package/dist/{shell → system}/fs/escape-posix-path.d.ts +0 -0
  118. /package/dist/{shell → system}/fs/escape-posix-path.js +0 -0
  119. /package/dist/{shell → system}/fs/escape-win32-path.d.ts +0 -0
  120. /package/dist/{shell → system}/fs/escape-win32-path.js +0 -0
  121. /package/dist/{net → system/net}/ephemeral-port.d.ts +0 -0
  122. /package/dist/{net → system/net}/ephemeral-port.js +0 -0
  123. /package/dist/{net → system/net}/inet-address.d.ts +0 -0
  124. /package/dist/{net → system/net}/inet-address.js +0 -0
  125. /package/dist/{net → system/net}/inet-endpoint.d.ts +0 -0
  126. /package/dist/{net → system/net}/inet-endpoint.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ephemeral-port.js","sourceRoot":"","sources":["../../../src/system/net/ephemeral-port.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C,yDAAyD;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C,MAAM,oBAAoB,GACzB,wBAAwB,GAAG,wBAAwB,GAAG,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACrC,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC7B,iFAAiF;IACjF,OAAO,wBAAwB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAE,GAAG,oBAAoB,CAAC,CAAC;AACrE,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inet-address.d.ts","sourceRoot":"","sources":["../../../src/system/net/inet-address.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG;IACzB,qEAAqE;IACrE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACrB,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC9B,OAAO,EAAE,MAAM,GACb,WAAW,CA6Bb"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inet-address.js","sourceRoot":"","sources":["../../../src/system/net/inet-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CACjC,MAA8B,EAC9B,OAAe;IAEf,IAAI,eAA6B,CAAC;IAElC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACvB,eAAe,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9B,eAAe,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,gBAAgB,CACzB,0BAA0B,MAAM,8BAA8B,CAC9D,CAAC;QACH,CAAC;IACF,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YAClC,eAAe,GAAG,MAAM,CAAC;QAC1B,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,gBAAgB,CACzB,0BAA0B,MAAM,kCAAkC,CAClE,CAAC;QACH,CAAC;IACF,CAAC;SAAM,CAAC;QACP,eAAe,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,OAAO;QACN,MAAM,EAAE,eAAe;QACvB,OAAO;KACP,CAAC;AACH,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inet-endpoint.d.ts","sourceRoot":"","sources":["../../../src/system/net/inet-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACxC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inet-endpoint.js","sourceRoot":"","sources":["../../../src/system/net/inet-endpoint.ts"],"names":[],"mappings":""}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ac-kit/core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Foundational JavaScript and TypeScript extensions with no domain knowledge: guards, type helpers, collection and string utilities, JSON, pattern matching, promises, time, errors and a byte cursor.",
5
5
  "keywords": [
6
6
  "esm",
@@ -51,7 +51,7 @@
51
51
  "devDependencies": {
52
52
  "@ac-kit/tsconfig": "0.1.0",
53
53
  "@ac-kit/typedoc-config": "0.1.0",
54
- "@ac-kit/vitest-config": "0.1.0",
54
+ "@ac-kit/vitest-config": "0.1.1",
55
55
  "@types/node": "26.5.1",
56
56
  "@typescript/native": "typescript@7.0.2",
57
57
  "rimraf": "6.1.3",
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if a value's own prototype is `Object.prototype` or null.
3
- *
4
- * Deliberately not `isPojo`, which follows the prototype chain and so also
5
- * accepts `Object.create({})`.
6
- */
7
- export declare function isPlainObject(value: object): boolean;
8
- //# sourceMappingURL=is-plain-object.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-plain-object.d.ts","sourceRoot":"","sources":["../../src/guards/is-plain-object.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAGpD"}
@@ -1,11 +0,0 @@
1
- /**
2
- * Check if a value's own prototype is `Object.prototype` or null.
3
- *
4
- * Deliberately not `isPojo`, which follows the prototype chain and so also
5
- * accepts `Object.create({})`.
6
- */
7
- export function isPlainObject(value) {
8
- const proto = Object.getPrototypeOf(value);
9
- return proto === Object.prototype || proto === null;
10
- }
11
- //# sourceMappingURL=is-plain-object.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-plain-object.js","sourceRoot":"","sources":["../../src/guards/is-plain-object.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa;IAC1C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,KAAK,KAAK,MAAM,CAAC,SAAS,IAAI,KAAK,KAAK,IAAI,CAAC;AACrD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ephemeral-port.d.ts","sourceRoot":"","sources":["../../src/net/ephemeral-port.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAE9C,yDAAyD;AACzD,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAK9C;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAK/C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"ephemeral-port.js","sourceRoot":"","sources":["../../src/net/ephemeral-port.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C,yDAAyD;AACzD,MAAM,CAAC,MAAM,wBAAwB,GAAG,KAAK,CAAC;AAE9C,MAAM,oBAAoB,GACzB,wBAAwB,GAAG,wBAAwB,GAAG,CAAC,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB;IACrC,MAAM,IAAI,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IAC7B,iFAAiF;IACjF,OAAO,wBAAwB,GAAG,CAAC,IAAI,CAAC,CAAC,CAAE,GAAG,oBAAoB,CAAC,CAAC;AACrE,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inet-address.d.ts","sourceRoot":"","sources":["../../src/net/inet-address.ts"],"names":[],"mappings":"AAEA,iEAAiE;AACjE,MAAM,MAAM,WAAW,GAAG;IACzB,qEAAqE;IACrE,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IACrB,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EAC9B,OAAO,EAAE,MAAM,GACb,WAAW,CA6Bb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inet-address.js","sourceRoot":"","sources":["../../src/net/inet-address.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUhD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,kBAAkB,CACjC,MAA8B,EAC9B,OAAe;IAEf,IAAI,eAA6B,CAAC;IAElC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAChC,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YACvB,eAAe,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9B,eAAe,GAAG,CAAC,CAAC;QACrB,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,gBAAgB,CACzB,0BAA0B,MAAM,8BAA8B,CAC9D,CAAC;QACH,CAAC;IACF,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,IAAI,MAAM,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,EAAE,CAAC;YAClC,eAAe,GAAG,MAAM,CAAC;QAC1B,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,gBAAgB,CACzB,0BAA0B,MAAM,kCAAkC,CAClE,CAAC;QACH,CAAC;IACF,CAAC;SAAM,CAAC;QACP,eAAe,GAAG,IAAI,CAAC;IACxB,CAAC;IAED,OAAO;QACN,MAAM,EAAE,eAAe;QACvB,OAAO;KACP,CAAC;AACH,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inet-endpoint.d.ts","sourceRoot":"","sources":["../../src/net/inet-endpoint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,yEAAyE;AACzE,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG;IACxC,mBAAmB;IACnB,IAAI,EAAE,MAAM,CAAC;CACb,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"inet-endpoint.js","sourceRoot":"","sources":["../../src/net/inet-endpoint.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-path.d.ts","sourceRoot":"","sources":["../../../src/shell/fs/escape-posix-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,SAAM,GAAG,MAAM,CAOtE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-path.js","sourceRoot":"","sources":["../../../src/shell/fs/escape-posix-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,WAAW,GAAG,GAAG;IAC7D,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACjB,CAAC;IAED,4CAA4C;IAC5C,OAAO,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AAC/D,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-win32-path.d.ts","sourceRoot":"","sources":["../../../src/shell/fs/escape-win32-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,SAAM,GAAG,MAAM,CAYtE"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-win32-path.js","sourceRoot":"","sources":["../../../src/shell/fs/escape-win32-path.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,GAAW,EAAE,WAAW,GAAG,GAAG;IAC7D,IAAI,+CAA+C,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/D,GAAG,GAAG,GAAG,WAAW,GAAG,GAAG,EAAE,CAAC;IAC9B,CAAC;IAED,OAAO,CACN,GAAG;QACF,4CAA4C;SAC3C,OAAO,CAAC,wBAAwB,EAAE,WAAW,CAAC;SAC9C,OAAO,CAAC,QAAQ,EAAE,WAAW,CAAC;SAC9B,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,CACnB,CAAC;AACH,CAAC"}
@@ -1,43 +0,0 @@
1
- import type { EnvVariable, EnvVariableValue } from "./types.js";
2
- /**
3
- * Parse a string as an environment variable definition.
4
- *
5
- * If the string does not contain an equal sign, the variable value will be
6
- * null.
7
- *
8
- * @param value The environment variable string to parse.
9
- * @returns The parsed environment variable.
10
- */
11
- export declare function parseEnvVariable(value: string): EnvVariable;
12
- /**
13
- * Parse a string value as an environment variable value.
14
- *
15
- * @param value The string value to parse.
16
- * @returns The parsed string, number, bigint, boolean value, or null if the
17
- * input is null or empty.
18
- */
19
- export declare function parseEnvVariableValue(value: string | undefined | null): EnvVariableValue;
20
- /**
21
- * Parse a string value as a string environment variable value.
22
- *
23
- * @param value The string value to parse.
24
- * @returns The parsed string value, or null if the value is null or empty.
25
- */
26
- export declare function parseEnvVariableValueAsString(value: string | undefined | null): string | null;
27
- /**
28
- * Parse a string value as a number or bigint environment variable value.
29
- *
30
- * @param value The string value to parse.
31
- * @returns The parsed number or bigint value, or null if the value is not a
32
- * valid number or bigint representation.
33
- */
34
- export declare function parseEnvVariableValueAsNumber(value: string | undefined | null): number | bigint | null;
35
- /**
36
- * Parse a string value as a boolean environment variable value.
37
- *
38
- * @param value The string value to parse.
39
- * @returns The parsed boolean value, or null if the value is not a valid
40
- * boolean representation.
41
- */
42
- export declare function parseEnvVariableValueAsBool(value: string | undefined | null): boolean | null;
43
- //# sourceMappingURL=parse-env-variable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-env-variable.d.ts","sourceRoot":"","sources":["../../../src/shell/process/parse-env-variable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEhE;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAS3D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CACpC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,gBAAgB,CAgBlB;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC5C,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,MAAM,GAAG,IAAI,CAUf;AAED;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC5C,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,MAAM,GAAG,MAAM,GAAG,IAAI,CAuBxB;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAC1C,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAC9B,OAAO,GAAG,IAAI,CAuBhB"}
@@ -1,109 +0,0 @@
1
- /**
2
- * Parse a string as an environment variable definition.
3
- *
4
- * If the string does not contain an equal sign, the variable value will be
5
- * null.
6
- *
7
- * @param value The environment variable string to parse.
8
- * @returns The parsed environment variable.
9
- */
10
- export function parseEnvVariable(value) {
11
- const eqIndex = value.indexOf("=");
12
- if (eqIndex === -1) {
13
- return { name: value, value: null };
14
- }
15
- const name = value.substring(0, eqIndex);
16
- const rawValue = value.substring(eqIndex + 1);
17
- return { name, value: parseEnvVariableValue(rawValue) };
18
- }
19
- /**
20
- * Parse a string value as an environment variable value.
21
- *
22
- * @param value The string value to parse.
23
- * @returns The parsed string, number, bigint, boolean value, or null if the
24
- * input is null or empty.
25
- */
26
- export function parseEnvVariableValue(value) {
27
- if (!value) {
28
- return null;
29
- }
30
- const num = parseEnvVariableValueAsNumber(value);
31
- if (num !== null) {
32
- return num;
33
- }
34
- const bool = parseEnvVariableValueAsBool(value);
35
- if (bool !== null) {
36
- return bool;
37
- }
38
- return parseEnvVariableValueAsString(value);
39
- }
40
- /**
41
- * Parse a string value as a string environment variable value.
42
- *
43
- * @param value The string value to parse.
44
- * @returns The parsed string value, or null if the value is null or empty.
45
- */
46
- export function parseEnvVariableValueAsString(value) {
47
- if (!value || value.length === 0) {
48
- return null;
49
- }
50
- if (value.startsWith('"') && value.endsWith('"')) {
51
- return JSON.parse(value);
52
- }
53
- return value;
54
- }
55
- /**
56
- * Parse a string value as a number or bigint environment variable value.
57
- *
58
- * @param value The string value to parse.
59
- * @returns The parsed number or bigint value, or null if the value is not a
60
- * valid number or bigint representation.
61
- */
62
- export function parseEnvVariableValueAsNumber(value) {
63
- if (!value) {
64
- return null;
65
- }
66
- try {
67
- const bn = BigInt(value);
68
- if (bn >= BigInt(Number.MIN_SAFE_INTEGER) &&
69
- bn <= BigInt(Number.MAX_SAFE_INTEGER)) {
70
- return Number(bn);
71
- }
72
- return bn;
73
- }
74
- catch {
75
- const num = Number(value);
76
- if (!Number.isNaN(num)) {
77
- return num;
78
- }
79
- }
80
- return null;
81
- }
82
- /**
83
- * Parse a string value as a boolean environment variable value.
84
- *
85
- * @param value The string value to parse.
86
- * @returns The parsed boolean value, or null if the value is not a valid
87
- * boolean representation.
88
- */
89
- export function parseEnvVariableValueAsBool(value) {
90
- if (!value) {
91
- return null;
92
- }
93
- switch (value.toLowerCase()) {
94
- case "1":
95
- case "true":
96
- case "yes":
97
- case "on":
98
- return true;
99
- case "0":
100
- case "false":
101
- case "no":
102
- case "off":
103
- return false;
104
- default:
105
- break;
106
- }
107
- return null;
108
- }
109
- //# sourceMappingURL=parse-env-variable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-env-variable.js","sourceRoot":"","sources":["../../../src/shell/process/parse-env-variable.ts"],"names":[],"mappings":"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"}
@@ -1,50 +0,0 @@
1
- import type { EnvVariableValue } from "./types.js";
2
- /**
3
- * Stringify a string environment variable value.
4
- *
5
- * If the string contains spaces, quotes, or equal signs, it will be quoted.
6
- *
7
- * @param value The string value to stringify.
8
- * @returns The stringified string value.
9
- */
10
- export declare function stringifyEnvVariableStringValue(value: string): string;
11
- /**
12
- * Stringify a number or bigint environment variable value.
13
- *
14
- * @param value The number or bigint value to stringify.
15
- * @returns The stringified number or bigint value.
16
- */
17
- export declare function stringifyEnvVariableNumberValue(value: number | bigint): string;
18
- export type EnvVariableBoolValueFlavor = "1/0" | "true/false" | "yes/no" | "on/off";
19
- /**
20
- * Stringify a boolean environment variable value according to the specified
21
- * flavor.
22
- *
23
- * @param value The boolean value to stringify.
24
- * @param flavor The flavor to use for stringifying the boolean value.
25
- * @returns The stringified boolean value.
26
- */
27
- export declare function stringifyEnvVariableBoolValue(value: boolean, flavor: EnvVariableBoolValueFlavor): string;
28
- export type StringifyEnvVariableValueOptions = {
29
- /** The flavor to use when stringifying boolean values. Defaults to "1/0". */
30
- boolFlavor?: EnvVariableBoolValueFlavor;
31
- };
32
- /**
33
- * Stringify an environment variable value.
34
- *
35
- * @param value The environment variable value.
36
- * @param options Options for stringifying the value.
37
- * @returns The stringified environment variable value.
38
- */
39
- export declare function stringifyEnvVariableValue(value: EnvVariableValue, options?: StringifyEnvVariableValueOptions): string;
40
- export type StringifyEnvVariableOptions = StringifyEnvVariableValueOptions;
41
- /**
42
- * Stringify an environment variable assignment (e.g., `KEY=value`)
43
- *
44
- * @param name The environment variable name.
45
- * @param value The environment variable value.
46
- * @param options Options for stringifying the value.
47
- * @returns The stringified environment variable assignment.
48
- */
49
- export declare function stringifyEnvVariable(name: string, value: EnvVariableValue, options?: StringifyEnvVariableOptions): string;
50
- //# sourceMappingURL=stringify-env-variable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringify-env-variable.d.ts","sourceRoot":"","sources":["../../../src/shell/process/stringify-env-variable.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;;;GAKG;AACH,wBAAgB,+BAA+B,CAC9C,KAAK,EAAE,MAAM,GAAG,MAAM,GACpB,MAAM,CAER;AAED,MAAM,MAAM,0BAA0B,GACnC,KAAK,GACL,YAAY,GACZ,QAAQ,GACR,QAAQ,CAAC;AAEZ;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAC5C,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,0BAA0B,GAChC,MAAM,CAcR;AAED,MAAM,MAAM,gCAAgC,GAAG;IAC9C,6EAA6E;IAC7E,UAAU,CAAC,EAAE,0BAA0B,CAAC;CACxC,CAAC;AAOF;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACxC,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE,gCAAgC,GACxC,MAAM,CA0BR;AAED,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,CAAC;AAO3E;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CACnC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,gBAAgB,EACvB,OAAO,CAAC,EAAE,2BAA2B,GACnC,MAAM,CAOR"}
@@ -1,86 +0,0 @@
1
- import { UnsupportedError, defaults } from "@ac-kit/core";
2
- /**
3
- * Stringify a string environment variable value.
4
- *
5
- * If the string contains spaces, quotes, or equal signs, it will be quoted.
6
- *
7
- * @param value The string value to stringify.
8
- * @returns The stringified string value.
9
- */
10
- export function stringifyEnvVariableStringValue(value) {
11
- return /[\s"'=]/.test(value) ? JSON.stringify(value) : value;
12
- }
13
- /**
14
- * Stringify a number or bigint environment variable value.
15
- *
16
- * @param value The number or bigint value to stringify.
17
- * @returns The stringified number or bigint value.
18
- */
19
- export function stringifyEnvVariableNumberValue(value) {
20
- return `${value}`;
21
- }
22
- /**
23
- * Stringify a boolean environment variable value according to the specified
24
- * flavor.
25
- *
26
- * @param value The boolean value to stringify.
27
- * @param flavor The flavor to use for stringifying the boolean value.
28
- * @returns The stringified boolean value.
29
- */
30
- export function stringifyEnvVariableBoolValue(value, flavor) {
31
- switch (flavor) {
32
- case "1/0":
33
- return value ? "1" : "0";
34
- case "true/false":
35
- return value ? "true" : "false";
36
- case "yes/no":
37
- return value ? "yes" : "no";
38
- case "on/off":
39
- return value ? "on" : "off";
40
- }
41
- }
42
- const STRINGIFY_ENV_VARIABLE_VALUE_DEFAULT_OPTIONS = {
43
- boolFlavor: "1/0",
44
- };
45
- /**
46
- * Stringify an environment variable value.
47
- *
48
- * @param value The environment variable value.
49
- * @param options Options for stringifying the value.
50
- * @returns The stringified environment variable value.
51
- */
52
- export function stringifyEnvVariableValue(value, options) {
53
- const effectiveOptions = defaults(options, STRINGIFY_ENV_VARIABLE_VALUE_DEFAULT_OPTIONS);
54
- switch (typeof value) {
55
- case "string":
56
- return stringifyEnvVariableStringValue(value);
57
- case "number":
58
- case "bigint":
59
- return stringifyEnvVariableNumberValue(value);
60
- case "boolean":
61
- return stringifyEnvVariableBoolValue(value, effectiveOptions.boolFlavor);
62
- case "object":
63
- if (value === null) {
64
- return "";
65
- }
66
- // else, fall through to throw
67
- default:
68
- throw new UnsupportedError(`value type "${typeof value}"`);
69
- }
70
- }
71
- const STRINGIFY_ENV_VARIABLE_DEFAULT_OPTIONS = {
72
- ...STRINGIFY_ENV_VARIABLE_VALUE_DEFAULT_OPTIONS,
73
- };
74
- /**
75
- * Stringify an environment variable assignment (e.g., `KEY=value`)
76
- *
77
- * @param name The environment variable name.
78
- * @param value The environment variable value.
79
- * @param options Options for stringifying the value.
80
- * @returns The stringified environment variable assignment.
81
- */
82
- export function stringifyEnvVariable(name, value, options) {
83
- const effectiveOptions = defaults(options, STRINGIFY_ENV_VARIABLE_DEFAULT_OPTIONS);
84
- return `${name}=${stringifyEnvVariableValue(value, effectiveOptions)}`;
85
- }
86
- //# sourceMappingURL=stringify-env-variable.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringify-env-variable.js","sourceRoot":"","sources":["../../../src/shell/process/stringify-env-variable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAI1D;;;;;;;GAOG;AACH,MAAM,UAAU,+BAA+B,CAAC,KAAa;IAC5D,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC9C,KAAsB;IAEtB,OAAO,GAAG,KAAK,EAAE,CAAC;AACnB,CAAC;AAQD;;;;;;;GAOG;AACH,MAAM,UAAU,6BAA6B,CAC5C,KAAc,EACd,MAAkC;IAElC,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,KAAK;YACT,OAAO,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;QAE1B,KAAK,YAAY;YAChB,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAEjC,KAAK,QAAQ;YACZ,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;QAE7B,KAAK,QAAQ;YACZ,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;IAC9B,CAAC;AACF,CAAC;AAOD,MAAM,4CAA4C,GACjD;IACC,UAAU,EAAE,KAAK;CACjB,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CACxC,KAAuB,EACvB,OAA0C;IAE1C,MAAM,gBAAgB,GAAG,QAAQ,CAChC,OAAO,EACP,4CAA4C,CAC5C,CAAC;IAEF,QAAQ,OAAO,KAAK,EAAE,CAAC;QACtB,KAAK,QAAQ;YACZ,OAAO,+BAA+B,CAAC,KAAK,CAAC,CAAC;QAE/C,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACZ,OAAO,+BAA+B,CAAC,KAAK,CAAC,CAAC;QAE/C,KAAK,SAAS;YACb,OAAO,6BAA6B,CAAC,KAAK,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAE1E,KAAK,QAAQ;YACZ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACpB,OAAO,EAAE,CAAC;YACX,CAAC;QACF,8BAA8B;QAE9B;YACC,MAAM,IAAI,gBAAgB,CAAC,eAAe,OAAO,KAAK,GAAG,CAAC,CAAC;IAC7D,CAAC;AACF,CAAC;AAID,MAAM,sCAAsC,GAC3C;IACC,GAAG,4CAA4C;CAC/C,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CACnC,IAAY,EACZ,KAAuB,EACvB,OAAqC;IAErC,MAAM,gBAAgB,GAAG,QAAQ,CAChC,OAAO,EACP,sCAAsC,CACtC,CAAC;IAEF,OAAO,GAAG,IAAI,IAAI,yBAAyB,CAAC,KAAK,EAAE,gBAAgB,CAAC,EAAE,CAAC;AACxE,CAAC"}
@@ -1,7 +0,0 @@
1
- export type EnvVariableValue = string | number | bigint | boolean | null;
2
- export type EnvVariable = {
3
- name: string;
4
- value: EnvVariableValue;
5
- };
6
- export type EnvVariables = Record<string, EnvVariableValue>;
7
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shell/process/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEzE,MAAM,MAAM,WAAW,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/shell/process/types.ts"],"names":[],"mappings":""}
@@ -1,20 +0,0 @@
1
- /**
2
- * Escape a string to be safely used as a shell argument in POSIX-compliant
3
- * shells
4
- *
5
- * It adds single quotes around a string and quotes/escapes any existing single
6
- * quotes.
7
- *
8
- * Example:
9
- *
10
- * ```ts
11
- * const unsafe = "It's a test";
12
- * const safe = escapeShellArgPosix(unsafe);
13
- * console.log(safe); // 'It'\''s a test'
14
- * ```
15
- *
16
- * @param expr The string to escape
17
- * @returns The escaped string
18
- */
19
- export declare function escapePosixShCommandArg(expr: string): string;
20
- //# sourceMappingURL=escape-posix-sh-command-arg.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-sh-command-arg.d.ts","sourceRoot":"","sources":["../../../src/shell/shell/escape-posix-sh-command-arg.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM5D"}
@@ -1,26 +0,0 @@
1
- import { escapePosixShSqe } from "./escape-posix-sh-sqe.js";
2
- /**
3
- * Escape a string to be safely used as a shell argument in POSIX-compliant
4
- * shells
5
- *
6
- * It adds single quotes around a string and quotes/escapes any existing single
7
- * quotes.
8
- *
9
- * Example:
10
- *
11
- * ```ts
12
- * const unsafe = "It's a test";
13
- * const safe = escapeShellArgPosix(unsafe);
14
- * console.log(safe); // 'It'\''s a test'
15
- * ```
16
- *
17
- * @param expr The string to escape
18
- * @returns The escaped string
19
- */
20
- export function escapePosixShCommandArg(expr) {
21
- if (expr === "") {
22
- return "''";
23
- }
24
- return `'${escapePosixShSqe(expr)}'`;
25
- }
26
- //# sourceMappingURL=escape-posix-sh-command-arg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-sh-command-arg.js","sourceRoot":"","sources":["../../../src/shell/shell/escape-posix-sh-command-arg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE5D;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAY;IACnD,IAAI,IAAI,KAAK,EAAE,EAAE,CAAC;QACjB,OAAO,IAAI,CAAC;IACb,CAAC;IAED,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC;AACtC,CAAC"}
@@ -1,19 +0,0 @@
1
- /**
2
- * Escapes any characters in a string that might be used to trick a
3
- * POSIX-compliant shell command into executing arbitrary commands.
4
- *
5
- * It escapes the following characters by adding a backslash before them:
6
- * &#;`|*?~<>^()[]{}$, \n and \xFF.
7
- *
8
- * The characters ' and " are escaped only if they are not paired.
9
- *
10
- * Based on PHP escapeshellcmd:
11
- * https://www.php.net/manual/en/function.escapeshellcmd.php
12
- *
13
- * Source code:
14
- * https://github.com/php/php-src/blob/d85662d6cc2c6d5f69403f6fb2001ff78e1bd174/ext/standard/exec.c#L270
15
- *
16
- * @param cmd The command to escape @returns The escaped command
17
- */
18
- export declare function escapePosixShCommand(cmd: string): string;
19
- //# sourceMappingURL=escape-posix-sh-command.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-sh-command.d.ts","sourceRoot":"","sources":["../../../src/shell/shell/escape-posix-sh-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAoCxD"}
@@ -1,55 +0,0 @@
1
- /**
2
- * Escapes any characters in a string that might be used to trick a
3
- * POSIX-compliant shell command into executing arbitrary commands.
4
- *
5
- * It escapes the following characters by adding a backslash before them:
6
- * &#;`|*?~<>^()[]{}$, \n and \xFF.
7
- *
8
- * The characters ' and " are escaped only if they are not paired.
9
- *
10
- * Based on PHP escapeshellcmd:
11
- * https://www.php.net/manual/en/function.escapeshellcmd.php
12
- *
13
- * Source code:
14
- * https://github.com/php/php-src/blob/d85662d6cc2c6d5f69403f6fb2001ff78e1bd174/ext/standard/exec.c#L270
15
- *
16
- * @param cmd The command to escape @returns The escaped command
17
- */
18
- export function escapePosixShCommand(cmd) {
19
- // Escape any of the special characters with a backslash
20
- cmd = cmd.replace(/([&#;`|*?~<>^()[\]{}$\\\n\xFF])/g, "\\$1");
21
- // Escape unpaired quotes by preceding them with a backslash
22
- let result = "";
23
- let lastMatchingQuoteIndex = -1;
24
- for (let i = 0; i < cmd.length; i++) {
25
- const c = cmd[i];
26
- if (c === "'" || c === '"') {
27
- if (lastMatchingQuoteIndex === -1) {
28
- lastMatchingQuoteIndex = cmd.indexOf(c, i + 1);
29
- if (lastMatchingQuoteIndex === -1) {
30
- // No matching quote found, escape this one
31
- result += `\\${c}`;
32
- }
33
- else {
34
- result += c;
35
- }
36
- }
37
- else {
38
- if (cmd[lastMatchingQuoteIndex] === c) {
39
- // Found the matching quote for the last opened quote
40
- lastMatchingQuoteIndex = -1;
41
- result += c;
42
- }
43
- else {
44
- // The quote is not matching the last opened quote, escape it
45
- result += `\\${c}`;
46
- }
47
- }
48
- }
49
- else {
50
- result += c;
51
- }
52
- }
53
- return result;
54
- }
55
- //# sourceMappingURL=escape-posix-sh-command.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-sh-command.js","sourceRoot":"","sources":["../../../src/shell/shell/escape-posix-sh-command.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC/C,wDAAwD;IACxD,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;IAE9D,4DAA4D;IAC5D,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,IAAI,sBAAsB,GAAG,CAAC,CAAC,CAAC;IAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;QAEjB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;YAC5B,IAAI,sBAAsB,KAAK,CAAC,CAAC,EAAE,CAAC;gBACnC,sBAAsB,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;gBAC/C,IAAI,sBAAsB,KAAK,CAAC,CAAC,EAAE,CAAC;oBACnC,2CAA2C;oBAC3C,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;gBACpB,CAAC;qBAAM,CAAC;oBACP,MAAM,IAAI,CAAC,CAAC;gBACb,CAAC;YACF,CAAC;iBAAM,CAAC;gBACP,IAAI,GAAG,CAAC,sBAAsB,CAAC,KAAK,CAAC,EAAE,CAAC;oBACvC,qDAAqD;oBACrD,sBAAsB,GAAG,CAAC,CAAC,CAAC;oBAC5B,MAAM,IAAI,CAAC,CAAC;gBACb,CAAC;qBAAM,CAAC;oBACP,6DAA6D;oBAC7D,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;gBACpB,CAAC;YACF,CAAC;QACF,CAAC;aAAM,CAAC;YACP,MAAM,IAAI,CAAC,CAAC;QACb,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC"}
@@ -1,13 +0,0 @@
1
- /**
2
- * Escape a string to be safely used in a single-quoted shell command.
3
- *
4
- * Example:
5
- *
6
- * ```ts
7
- * const unsafe = "It's a test";
8
- * const safe = escapePosixShSqe(unsafe);
9
- * console.log(safe); // It'\''s a test
10
- * ```
11
- */
12
- export declare function escapePosixShSqe(expr: string): string;
13
- //# sourceMappingURL=escape-posix-sh-sqe.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-sh-sqe.d.ts","sourceRoot":"","sources":["../../../src/shell/shell/escape-posix-sh-sqe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAErD"}
@@ -1,15 +0,0 @@
1
- /**
2
- * Escape a string to be safely used in a single-quoted shell command.
3
- *
4
- * Example:
5
- *
6
- * ```ts
7
- * const unsafe = "It's a test";
8
- * const safe = escapePosixShSqe(unsafe);
9
- * console.log(safe); // It'\''s a test
10
- * ```
11
- */
12
- export function escapePosixShSqe(expr) {
13
- return expr.replace(/'/g, "'\\''");
14
- }
15
- //# sourceMappingURL=escape-posix-sh-sqe.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"escape-posix-sh-sqe.js","sourceRoot":"","sources":["../../../src/shell/shell/escape-posix-sh-sqe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AACpC,CAAC"}