2.3.6 โ€ข Published 2 years ago

io-run v2.3.6

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

๐Ÿ”Œ IO-RUN

 import 'io-run'

 await $`echo Hello World!`

 let branch = await $ `git rev-parse --abbrev-ref HEAD`
 $ `git checkout ${branch}`

Simple to run command line for nodejs with typescript ๐Ÿ”ฅ

๐Ÿ•น Install

 $ yarn add io-run
 $ npm install io-run

๐Ÿ”จ How to use it?

import { $ } from 'io-run'
//or
import 'io-run'

The $ function executes the given command line using the spawn function of the child process module.

 let user = await $ `whoami`
 console.log(user)

If the program returns a non-zero exit code, ProcessOutput will be thrown.

 ProcessOutput {
   stdout: 
   stderr: 'HOLY' is not recognized as an internal or external command, operable program or batch file.
   code: 1
 }

๐Ÿ’ฟ Configuration

๐Ÿ–ฅ๏ธ $.shell

Specifies the shell to use. Default is /bin/sh on Unix, process.env.ComSpec on Windows. or use cli argument: --shell

 $.shell = which('powershell') //C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

which function is implemented to find the path.

๐Ÿ“ $.prefix

Specifies the prefix for all commands run. or use a cli argument: --prefix

๐Ÿงพ $.verbose

Specifies verbosity. Default is false. prints all executed commands output using process.stdout.

๐Ÿ”— $.stdio

Specifies the stdio of the subprocess. The default is pipe.

 $.stdio = ['inherit', 'pipe', 'pipe'] // [stdin, stdout, stderr]

More information about stdio can be found here.

๐Ÿงท ELSE?

๐Ÿ“ cd function: changes the current working directory.

 cd('src')
 await $ `node test.js`

๐Ÿ’Š isWindow: returns true if os is windows.

 $ `${ isWindow ? 'explorer.exe' : 'open' } https://www.google.com`

๐Ÿ“‹ License

Distributed under the MIT License. See LICENSE for more information.

ยฉ 2022 IXFX, All rights reserved.

2.3.6

2 years ago

2.3.5

2 years ago

2.3.4

2 years ago

2.3.3

2 years ago

2.3.2

2 years ago

2.3.1

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.0.0

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago