kempo 2.10.3 → 2.10.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/dist/utils/cli.js +1 -1
- package/docs/kempo/utils/cli.js +1 -1
- package/package.json +1 -1
- package/src/utils/cli.js +17 -1
package/dist/utils/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn}from"child_process";const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export const getArgs=(e={d:"debug"})=>{let s="",
|
|
1
|
+
import{spawn}from"child_process";import readline from"readline";const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export const getArgs=(e={d:"debug"})=>{let s="",r=[];const o=()=>{s&&(0===r.length?args[s]=!0:1===r.length?"false"===r[0]?args[s]=!1:args[s]=r[0]:args[s]=r)};for(let t=2;t<process.argv.length;t++){const n=process.argv[t];n.startsWith("-")?(o(),n.startsWith("--")?s=n.slice(2):(s=n.slice(1),e[s]&&(s=e[s])),r=[]):r.push(n)}return o(),args};export const runChildProcess=e=>new Promise(((s,r)=>{const[o,...t]=e.split(" ");spawn(o,t).on("close",(e=>{0===e?s(`child process exited with code ${e}`):r(new Error(`child process exited with code ${e}`))}))}));export const runChildNodeProcess=(e,s={})=>{const r=`node ${e} ${Object.entries(s).flatMap((([e,s])=>!0===s?[`--${e}`]:[`--${e}`,s])).join(" ")}`;return runChildProcess(r)};export const promptUser=e=>{const s=readline.createInterface({input:process.stdin,output:process.stdout});return new Promise((r=>{s.question(e,(e=>{s.close(),r(e)}))}))};export default{getArgs:getArgs,runChildNodeProcess:runChildNodeProcess,runChildNodeProcess:runChildNodeProcess,promptUser:promptUser};
|
package/docs/kempo/utils/cli.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn}from"child_process";const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export const getArgs=(e={d:"debug"})=>{let s="",
|
|
1
|
+
import{spawn}from"child_process";import readline from"readline";const args={};let win={};"undefined"!=typeof window?win=window:"undefined"!=typeof global&&(win=global),win.log=(...e)=>{args.debug&&console.log(...e)};export const getArgs=(e={d:"debug"})=>{let s="",r=[];const o=()=>{s&&(0===r.length?args[s]=!0:1===r.length?"false"===r[0]?args[s]=!1:args[s]=r[0]:args[s]=r)};for(let t=2;t<process.argv.length;t++){const n=process.argv[t];n.startsWith("-")?(o(),n.startsWith("--")?s=n.slice(2):(s=n.slice(1),e[s]&&(s=e[s])),r=[]):r.push(n)}return o(),args};export const runChildProcess=e=>new Promise(((s,r)=>{const[o,...t]=e.split(" ");spawn(o,t).on("close",(e=>{0===e?s(`child process exited with code ${e}`):r(new Error(`child process exited with code ${e}`))}))}));export const runChildNodeProcess=(e,s={})=>{const r=`node ${e} ${Object.entries(s).flatMap((([e,s])=>!0===s?[`--${e}`]:[`--${e}`,s])).join(" ")}`;return runChildProcess(r)};export const promptUser=e=>{const s=readline.createInterface({input:process.stdin,output:process.stdout});return new Promise((r=>{s.question(e,(e=>{s.close(),r(e)}))}))};export default{getArgs:getArgs,runChildNodeProcess:runChildNodeProcess,runChildNodeProcess:runChildNodeProcess,promptUser:promptUser};
|
package/package.json
CHANGED
package/src/utils/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
|
+
import readline from 'readline';
|
|
2
3
|
|
|
3
4
|
const args = {};
|
|
4
5
|
let win = {};
|
|
@@ -84,8 +85,23 @@ export const runChildNodeProcess = (scriptPath, argsObj = {}) => {
|
|
|
84
85
|
return runChildProcess(command);
|
|
85
86
|
};
|
|
86
87
|
|
|
88
|
+
export const promptUser = (query) => {
|
|
89
|
+
const rl = readline.createInterface({
|
|
90
|
+
input: process.stdin,
|
|
91
|
+
output: process.stdout
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return new Promise((resolve) => {
|
|
95
|
+
rl.question(query, (answer) => {
|
|
96
|
+
rl.close();
|
|
97
|
+
resolve(answer);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
87
102
|
export default {
|
|
88
103
|
getArgs,
|
|
89
104
|
runChildNodeProcess,
|
|
90
|
-
runChildNodeProcess
|
|
105
|
+
runChildNodeProcess,
|
|
106
|
+
promptUser
|
|
91
107
|
};
|