@take-out/scripts 0.1.28 → 0.1.29
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/package.json +2 -2
- package/src/cmd.ts +21 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@take-out/scripts",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./src/run.ts",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@clack/prompts": "^0.8.2",
|
|
32
32
|
"@lydell/node-pty": "^1.2.0-beta.3",
|
|
33
|
-
"@take-out/helpers": "0.1.
|
|
33
|
+
"@take-out/helpers": "0.1.29",
|
|
34
34
|
"picocolors": "^1.1.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
package/src/cmd.ts
CHANGED
|
@@ -26,6 +26,7 @@ export function setInterceptCmd(
|
|
|
26
26
|
|
|
27
27
|
function createCmd(description: string) {
|
|
28
28
|
let argsSpec: string | undefined
|
|
29
|
+
let envVars: Record<string, string> = {}
|
|
29
30
|
|
|
30
31
|
function makeRun<S extends string>(spec: S): RunFn<S> {
|
|
31
32
|
return async (fn) => {
|
|
@@ -50,6 +51,11 @@ function createCmd(description: string) {
|
|
|
50
51
|
process.exit(0)
|
|
51
52
|
}
|
|
52
53
|
|
|
54
|
+
// apply env vars before running
|
|
55
|
+
for (const [key, value] of Object.entries(envVars)) {
|
|
56
|
+
process.env[key] = value
|
|
57
|
+
}
|
|
58
|
+
|
|
53
59
|
const [{ $ }, prompt, { run }, { args: parseArgs }, fs, path, os] =
|
|
54
60
|
await Promise.all([
|
|
55
61
|
import(`bun`),
|
|
@@ -68,10 +74,24 @@ function createCmd(description: string) {
|
|
|
68
74
|
}
|
|
69
75
|
}
|
|
70
76
|
|
|
77
|
+
function makeChainable<S extends string>(spec: S) {
|
|
78
|
+
return {
|
|
79
|
+
env(vars: Record<string, string>) {
|
|
80
|
+
Object.assign(envVars, vars)
|
|
81
|
+
return this
|
|
82
|
+
},
|
|
83
|
+
run: makeRun(spec),
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
71
87
|
return {
|
|
88
|
+
env(vars: Record<string, string>) {
|
|
89
|
+
Object.assign(envVars, vars)
|
|
90
|
+
return this
|
|
91
|
+
},
|
|
72
92
|
args<const S extends string>(spec: S) {
|
|
73
93
|
argsSpec = spec
|
|
74
|
-
return
|
|
94
|
+
return makeChainable(spec)
|
|
75
95
|
},
|
|
76
96
|
run: makeRun(`` as ``),
|
|
77
97
|
}
|