Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aweiu/wow-shell
shell command, it will be resolved when something is hit, and support the output of colored logs
https://github.com/aweiu/wow-shell
exec monorepo promise pshell shell spawn
Last synced: 6 days ago
JSON representation
shell command, it will be resolved when something is hit, and support the output of colored logs
- Host: GitHub
- URL: https://github.com/aweiu/wow-shell
- Owner: aweiu
- Created: 2022-02-09T17:44:09.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2022-02-10T07:21:34.000Z (almost 3 years ago)
- Last Synced: 2024-09-17T05:08:51.986Z (about 2 months ago)
- Topics: exec, monorepo, promise, pshell, shell, spawn
- Language: TypeScript
- Homepage:
- Size: 106 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## wow-shell
Shell command, it will be resolved when something is hit, and support the output of colored logs.
It is very suitable for writing your monorepo development service!
### Install
```
npm install wow-shell
```### Example1
```javascript
import shell from "wow-shell";// when stdout data includes 「Listening on port」, the shell promise will be resolved
shell("node ./packages/server/src/index.js", {
resolveKeyWords: "Listening on port",
}).then((matchedMsg) => {
console.log("matchedMsg:", matchedMsg);// run vite after the server runs successfully
shell("vite ./packages/webapp");
});
```The output in console:
```
server Listening on port 3000
matchedMsg: server Listening on port 3000vite v2.x.x dev server running at:
> Local: http://localhost:xxxx/
> Network: use `--host` to exposeready in xms.
```### Example2
```javascript
import shell from "wow-shell";// If the resolvekeywords parameter is not passed in, the shell promise will be resolved when the child process closed
shell("ping google.com").then(() => console.log("ping completed!"));
```The output in console:
```
PING google.com (x.x.x.x): x data bytes
x bytes from x.x.x.x: icmp_seq=0 ttl=x time=x ms
x bytes from x.x.x.x: icmp_seq=0 ttl=x time=x ms
x bytes from x.x.x.x: icmp_seq=0 ttl=x time=x ms--- google.com ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = x/x/x/x ms
ping completed!
```### API
shell(command: string, options: Omit<[SpawnOptionsWithoutStdio](http://nodejs.cn/api/child_process.html#child_processspawncommand-args-options), 'shell' | 'stdio'> & { resolveKeyWords?: string; })