# @ironche/node-bash

> bash-like commands in nodejs

Latest version **1.2.0** (published 2020-12-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install @ironche/node-bash
pnpm add @ironche/node-bash
yarn add @ironche/node-bash
bun add @ironche/node-bash
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2020-12-23 |
| First published | 2020-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Milos Manojlovic |
| Maintainers | ironche |
| Keywords | bash, shell, commands |

## Links

- npm: https://www.npmjs.com/package/@ironche/node-bash
- Repository: https://github.com/ironche/node-bash
- Homepage: https://github.com/ironche/node-bash#readme
- Issues: https://github.com/ironche/node-bash/issues
- npm.io page: https://npm.io/package/@ironche/node-bash

## Recent versions

- 1.2.0 (latest) — 2020-12-23
- 1.1.2 — 2020-12-15
- 1.1.1 — 2020-12-08
- 1.1.0 — 2020-12-05
- 1.0.0 — 2020-11-25

## README

# Node BASH

This project aims to provide NodeJS implementation of frequently used BASH commands and extend their functionality even further.

![AppVeyor](https://img.shields.io/appveyor/build/ironche/node-bash?logo=appveyor)
![AppVeyor tests](https://img.shields.io/appveyor/tests/ironche/node-bash?logo=appveyor)
![npm](https://img.shields.io/npm/dm/@ironche/node-bash?logo=npm)

## Installation

```shell
npm install @ironche/node-bash
```

## Contents

- **find** - search for files and folders in a folder hierarchy
- **grep** - find files containing patterns

# Function find()

Traverse file system and search for files and folders recursively.

## Syntax

**Note**: All arguments are optional.

| Argument | Description |
| -------- | ----------- |
| path  | Folder from where the search begins. If omitted, the default value is the current folder, which is identical to './' |
| descriptor | Pass 'f' to search only for files, 'd' to search only for folders/directories, or null (anything else) if the search applies to both. |
| namePatterns | Regular expression (or array of regular expressions) to match names of files and folders and return them as result. Matches all names if omitted. |
| excludeFolders | Regular expression (or array of regular expressions) to exclude folders and their contents from search results. |
| depth | Used to limit the depth while traversing file system. Set to 0 to search only current level without entering any folders, 1 to go down one level, and so on. If omitted, traverses whole folder tree. |

**Return value**: array of objects found.

```js
import { find } from '@ironche/node-bash';
let args, results;

// find-example-1.js
args = ['.', 'f', null, /node_modules/];
results = find(...args).map((f) => f.path);
console.log(results);

/* example output
[
  './.gitignore',
  './index.js',
  './package-lock.json',
  './package.json'
]
*/

// find-example-2.js
args = ['.', 'f', /\.json$/, /node_modules/];
results = find(...args).map((f) => f.path);
console.log(results);

/* example output
[
  './package-lock.json',
  './package.json'
]
*/
```

# Function grep()

Read files and return those containing matched patterns.

## Syntax

**Note**: All arguments are optional.

| Argument | Description |
| -------- | ----------- |
| patterns  | Regular expression (or array of regular expressions) to match content of files and return files as result. Doesn't match any file if omitted. |
| files | Array of files found by using **find** function. |

**Return value**: array of files that contain given patterns.

```js
import { find, grep } from '@ironche/node-bash';

// find all files having extension "css"
const files = find('.', 'f', /\.css$/, /node_modules/);
// among supplied files, return only those containing text "white"
const results = grep(/white/, files);
console.log(results);

/* example output
[
  './theme-light.css',
  './button.css',
]
*/
```

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