@j-o-r/sh 1.1.11 → 1.1.12

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 (2) hide show
  1. package/lib/SH.js +12 -7
  2. package/package.json +2 -3
package/lib/SH.js CHANGED
@@ -89,6 +89,7 @@ const parseDuration = (d) => {
89
89
  }
90
90
  throw new Error(`Unknown duration: "${d}".`);
91
91
  }
92
+
92
93
  /** @type {Shell & { (pieces: TemplateStringsArray, ...args: *): SHDispatch }} */
93
94
  const SH = new Proxy(function(pieces, ...args) {
94
95
  if (pieces.some((p) => p == undefined)) {
@@ -98,7 +99,7 @@ const SH = new Proxy(function(pieces, ...args) {
98
99
  while (i < args.length) {
99
100
  let s;
100
101
  if (Array.isArray(args[i])) {
101
- s = args[i].map((x) => {
102
+ s = args[i].map(/** @param {string} x */(x) => {
102
103
  let str = String(x);
103
104
  // If the string contains special characters, wrap in single quotes
104
105
  if (str.match(/[ "'$`(){}[\]]/)) {
@@ -108,12 +109,16 @@ const SH = new Proxy(function(pieces, ...args) {
108
109
  return str;
109
110
  }).join(' ');
110
111
  } else {
111
- let str = String(args[i]);
112
- if (str.match(/[ "'$`(){}[\]]/)) {
113
- s = `'${str.replace(/'/g, `'\\''`)}'`;
114
- } else {
115
- s = str;
116
- }
112
+ // let str = String(args[i]);
113
+ // if (str.match(/[ "'$`(){}[\]]/)) {
114
+ // s = `'${str.replace(/'/g, `'\\''`)}'`;
115
+ // } else {
116
+ // s = str;
117
+ // }
118
+ // Leave string UNALTERED
119
+ // Should be escaped in the code and is the responsibility of the developer
120
+ // SH`do something "${filename}"`;
121
+ s = String(args[i]);
117
122
  }
118
123
  cmd += s + pieces[++i];
119
124
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@j-o-r/sh",
3
3
  "author": "Jorrit Duin <j-o-r@duin.work>",
4
4
  "type": "module",
5
- "version": "1.1.11",
5
+ "version": "1.1.12",
6
6
  "description": "Execute shell commands on Linux-based systems from javascript",
7
7
  "main": "lib/SH.js",
8
8
  "types": "types/SH.d.ts",
@@ -14,8 +14,7 @@
14
14
  "test:sh": "scenarios/sh.js",
15
15
  "publish": "npm run release && npm publish --access public",
16
16
  "release": "npm pack --pack-destination=release",
17
- "types": "tsc -p tsc.json",
18
- "clear:types": "rm types/*.d.ts"
17
+ "types": "rm types/* && tsc -p tsc.json"
19
18
  },
20
19
  "repository": {
21
20
  "type": "git",