dollar-shell 1.0.3 → 1.0.5
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/README.md +6 -4
- package/package.json +15 -6
- package/src/bq-spawn.js +41 -30
package/README.md
CHANGED
|
@@ -204,7 +204,9 @@ BSD-3-Clause
|
|
|
204
204
|
|
|
205
205
|
## Release History
|
|
206
206
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
207
|
+
* 1.0.5 *Updated dev dependencies.*
|
|
208
|
+
* 1.0.4 *Fixed `raw()` for spawn commands.*
|
|
209
|
+
* 1.0.3 *Added TSDoc comments, improved docs, fixed typos, added the missing copying of properties.*
|
|
210
|
+
* 1.0.2 *Technical release: fixed references in the package file.*
|
|
211
|
+
* 1.0.1 *Technical release: more tests, better documentation.*
|
|
212
|
+
* 1.0.0 *The initial release.*
|
package/package.json
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dollar-shell",
|
|
3
3
|
"description": "Run shell commands and use them in streams with ease in Node, Deno, Bun. Tiny, simple, no dependency package.",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
|
-
".":
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./src/index.d.ts",
|
|
11
|
+
"default": "./src/index.js"
|
|
12
|
+
},
|
|
10
13
|
"./*": "./src/*"
|
|
11
14
|
},
|
|
12
15
|
"scripts": {
|
|
13
16
|
"test": "tape6 --flags FO",
|
|
14
|
-
"
|
|
17
|
+
"test:bun": "tape6-bun --flags FO",
|
|
18
|
+
"test:deno": "deno run -A `tape6-runner main` --flags FO",
|
|
19
|
+
"test:deno-original": "tape6-deno --flags FO",
|
|
20
|
+
"ts-check": "tsc --noEmit"
|
|
15
21
|
},
|
|
16
22
|
"files": [
|
|
17
23
|
"/src",
|
|
@@ -34,11 +40,14 @@
|
|
|
34
40
|
"stream"
|
|
35
41
|
],
|
|
36
42
|
"author": "Eugene Lazutkin <eugene.lazutkin@gmail.com> (http://www.lazutkin.com/)",
|
|
37
|
-
"funding":
|
|
43
|
+
"funding": {
|
|
44
|
+
"type": "github",
|
|
45
|
+
"url": "https://github.com/sponsors/uhop"
|
|
46
|
+
},
|
|
38
47
|
"license": "BSD-3-Clause",
|
|
39
48
|
"devDependencies": {
|
|
40
|
-
"tape-six": "^0.
|
|
41
|
-
"typescript": "^5.
|
|
49
|
+
"tape-six": "^0.12.1",
|
|
50
|
+
"typescript": "^5.6.2"
|
|
42
51
|
},
|
|
43
52
|
"tape6": {
|
|
44
53
|
"tests": [
|
package/src/bq-spawn.js
CHANGED
|
@@ -2,6 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
import {verifyStrings, isRawValue, getRawValue} from './utils.js';
|
|
4
4
|
|
|
5
|
+
const appendString = (s, previousSpace, result) => {
|
|
6
|
+
previousSpace ||= /^\s/.test(s);
|
|
7
|
+
if (previousSpace) s = s.trimStart();
|
|
8
|
+
|
|
9
|
+
const lastSpace = /\s$/.test(s);
|
|
10
|
+
if (lastSpace) s = s.trimEnd();
|
|
11
|
+
|
|
12
|
+
let parts = s.split(/\s+/g).filter(part => part);
|
|
13
|
+
if (parts.length) {
|
|
14
|
+
if (!previousSpace) {
|
|
15
|
+
if (result.length) {
|
|
16
|
+
result[result.length - 1] += parts[0];
|
|
17
|
+
} else {
|
|
18
|
+
result.push(parts[0]);
|
|
19
|
+
}
|
|
20
|
+
parts = parts.slice(1);
|
|
21
|
+
}
|
|
22
|
+
result.push(...parts);
|
|
23
|
+
previousSpace = lastSpace;
|
|
24
|
+
} else {
|
|
25
|
+
previousSpace ||= lastSpace;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return previousSpace;
|
|
29
|
+
};
|
|
30
|
+
|
|
5
31
|
const impl =
|
|
6
32
|
(spawn, options) =>
|
|
7
33
|
(strings, ...args) => {
|
|
@@ -11,45 +37,30 @@ const impl =
|
|
|
11
37
|
for (let i = 0; i < strings.length; i++) {
|
|
12
38
|
// process a string
|
|
13
39
|
|
|
14
|
-
|
|
15
|
-
previousSpace ||= /^\s/.test(string);
|
|
16
|
-
if (previousSpace) string = string.trimStart();
|
|
17
|
-
const lastSpace = /\s$/.test(string);
|
|
18
|
-
if (lastSpace) string = string.trimEnd();
|
|
19
|
-
|
|
20
|
-
let parts = string.split(/\s+/g).filter(part => part);
|
|
21
|
-
if (parts.length) {
|
|
22
|
-
if (!previousSpace) {
|
|
23
|
-
if (result.length) {
|
|
24
|
-
result[result.length - 1] += parts[0];
|
|
25
|
-
} else {
|
|
26
|
-
result.push(parts[0]);
|
|
27
|
-
}
|
|
28
|
-
parts = parts.slice(1);
|
|
29
|
-
}
|
|
30
|
-
result.push(...parts);
|
|
31
|
-
previousSpace = lastSpace;
|
|
32
|
-
} else {
|
|
33
|
-
previousSpace ||= lastSpace;
|
|
34
|
-
}
|
|
40
|
+
previousSpace = appendString(strings[i], previousSpace, result);
|
|
35
41
|
|
|
36
42
|
// process an argument
|
|
37
43
|
|
|
38
44
|
if (i >= args.length) continue;
|
|
39
45
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
result.push(arg);
|
|
46
|
+
if (isRawValue(args[i])) {
|
|
47
|
+
const arg = String(getRawValue(args[i]));
|
|
48
|
+
if (!arg) continue;
|
|
49
|
+
previousSpace = appendString(arg, previousSpace, result);
|
|
45
50
|
} else {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
const arg = String(args[i]);
|
|
52
|
+
if (!arg) continue;
|
|
53
|
+
if (previousSpace) {
|
|
49
54
|
result.push(arg);
|
|
55
|
+
} else {
|
|
56
|
+
if (result.length) {
|
|
57
|
+
result[result.length - 1] += arg;
|
|
58
|
+
} else {
|
|
59
|
+
result.push(arg);
|
|
60
|
+
}
|
|
50
61
|
}
|
|
62
|
+
previousSpace = false;
|
|
51
63
|
}
|
|
52
|
-
previousSpace = false;
|
|
53
64
|
}
|
|
54
65
|
|
|
55
66
|
return spawn(result, options);
|