# @js-sh/js-sh

> Using the bash command simply for Javascript/Typescript

Latest version **0.1.1** (published 2023-10-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @js-sh/js-sh
pnpm add @js-sh/js-sh
yarn add @js-sh/js-sh
bun add @js-sh/js-sh
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2023-10-26 |
| First published | 2023-07-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 5.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | AryloYeung |
| Maintainers | arylo |
| Keywords | shell, bash, sh, unix |

## Links

- npm: https://www.npmjs.com/package/@js-sh/js-sh
- npm.io page: https://npm.io/package/@js-sh/js-sh

## Dependencies (2)

- [@js-sh/core](https://npm.io/package/@js-sh/core.md) ^0.1.1
- [@js-sh/system](https://npm.io/package/@js-sh/system.md) ^0.1.1

## Alternatives

- [csv-to-markdown-table](https://npm.io/package/csv-to-markdown-table.md) — 47.0K weekly downloads
- [@sapphire/ratelimits](https://npm.io/package/@sapphire/ratelimits.md) — 4.4K weekly downloads
- [js-csvparser](https://npm.io/package/js-csvparser.md) — 2.0K weekly downloads
- [@adadapted/js-sdk](https://npm.io/package/@adadapted/js-sdk.md) — 251 weekly downloads
- [@grapecity/spread-sheets-sparklines](https://npm.io/package/@grapecity/spread-sheets-sparklines.md) — 103 weekly downloads

## Recent versions

- 0.1.1 (latest) — 2023-10-26
- 0.1.0 — 2023-09-10
- 0.0.6 — 2023-09-04
- 0.0.5 — 2023-08-28
- 0.0.4 — 2023-08-16
- 0.0.3 — 2023-08-13
- 0.0.2 — 2023-08-04
- 0.0.1 — 2023-07-31

## README

# @js-sh/js-sh

Using the bash command simply for Javascript/Typescript

## Install

```bash
npm i @js-sh/js-sh
```

## Usage

### Example

```javascript
import { ls, cp, mkdir, rm } from '@js-sh/js-sh'

const CACHE_FOLDER = '.nyc_output'

rm(CACHE_FOLDER)
mkdir(CACHE_FOLDER)

ls('./apps/*/coverage/coverage-final.json')
  .forEach((p) => {
    cp.force(p, `${CACHE_FOLDER}/`)
  })
```

<details>
<summary><h2>Functions</h2></summary>


### $(command: string)

```javascript
import { $ } from '@js-sh/js-sh'

await $('npm run test')
```

### within(callback: Function)

```javascript
import { within } from '@js-sh/js-sh'

within(() => {
  cd('./oneFolder')
})

await within(async () => {
  cd('./otherFolder')
})
```

### retry(time: number, callback: Function)

```javascript
import { retry } from '@js-sh/js-sh'

await retry(3, async () => {
  // ...
})
```

### cat(path: string)

```javascript
import { cat } from '@js-sh/js-sh'

cat('./package.json')
```

### cd(path: string)

```javascript
import { cd } from '@js-sh/js-sh'

cd('./apps')
```

### cp(source: string, target: string, options?: { force: boolean })

#### Copy File to File

```javascript
import { cp } from '@js-sh/js-sh'

cp('./package.json', './package-backup.json')
```

#### Copy File into Folder

```javascript
import { cp } from '@js-sh/js-sh'

cp('./package.json', './targetFolder/')
```

#### Copy Folder to Folder

```javascript
import { cp } from '@js-sh/js-sh'

cp('./sourceFolder/*', './targetFolder')
```

#### Copy Folder into Folder

```javascript
import { cp } from '@js-sh/js-sh'

cp('./sourceFolder', './targetFolder/')
```

### cp.force(source: string, target: string)

See `cp` method

### echo(content: string)

```javascript
import { echo } from '@js-sh/js-sh'

echo('Hello World')
```

### ls(path: string | string[])

```javascript
import { ls } from '@js-sh/js-sh'

ls('./')
ls('./package.json')
ls('./apps', './packages')
```

### mkdir(path: string)

```javascript
import { mkdir } from '@js-sh/js-sh'

mkdir('./newFolder')
```

### mv(source: string, target: string, options?: { force: boolean })

#### Move File to File

```javascript
import { mv } from '@js-sh/js-sh'

mv('./package.json', './package-backup.json')
```

#### Move File into Folder

```javascript
import { mv } from '@js-sh/js-sh'

mv('./package.json', './targetFolder/')
```

#### Move Folder to Folder

```javascript
import { mv } from '@js-sh/js-sh'

mv('./sourceFolder/*', './targetFolder')
```

#### Move Folder into Folder

```javascript
import { mv } from '@js-sh/js-sh'

mv('./sourceFolder', './targetFolder/')
```

### mv.force(source: string, target: string)

See `mv` method

### pwd()

Default return the `process.cwd()` value until you use the `cd` method

```javascript
import { pwd } from '@js-sh/js-sh'

pwd()
```

### rm(path: string)

```javascript
import { rm } from '@js-sh/js-sh'

rm('./oldFolder')
```

### sleep(time: number)

```javascript
import { sleep } from '@js-sh/js-sh'

await sleep(50)
```

### exit(code: number, msg?: string)

```javascript
import { exit } from '@js-sh/js-sh'

exit(0, 'Bye~')
```

### readFile(filepath: string, encoding?: string)

```javascript
import { readFile } from '@js-sh/js-sh'

readFile('foo.txt', 'utf-8')
```

### writeFile(filepath: string, data: any, encoding?: string)

```javascript
import { writeFile } from '@js-sh/js-sh'

writeFile('foo.txt', '["Test"]', 'utf-8')
```

</details>

---
_Source: https://npm.io/package/@js-sh/js-sh · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
