# glops

> Library and CLI tools to perform operations on files and directories matched with glob patterns.

Latest version **0.0.4** (published 2023-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install glops
pnpm add glops
yarn add glops
bun add glops
```

Provides the commands `gcp`, `gmv`.

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2023-06-12 |
| First published | 2023-06-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Nex Zhu |
| Maintainers | nex |
| Keywords | TypeScript, library |

## Links

- npm: https://www.npmjs.com/package/glops
- Repository: https://github.com/daotl/glops
- Homepage: https://github.com/daotl/glops#readme
- Issues: https://github.com/daotl/glops/issues
- npm.io page: https://npm.io/package/glops

## Dependencies (1)

- [fast-glob](https://npm.io/package/fast-glob.md) ^3.2.12

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2023-06-12
- 0.0.3 — 2023-06-12
- 0.0.2 — 2023-06-12
- 0.0.1 — 2023-06-12

## README

# glob-operations (glops)

Library to perform operations on files and directories matched with glob patterns.

Also provides CLI tools: `gmv` for `mv`, and `gcp` for `cp` with glob patterns.

## Usage

```sh
npm install glops
```

```ts
op: (
  fn: (file: string, dest: string) => Promise<void>,
) => (globs: string[], destPattern: string) => Promise<void>
```

You can pass multiple glob patterns with `globs` which will be passed to [fast-glob](https://github.com/mrmlnc/fast-glob).

`destPattern` can contain the following placeholders:
- `{p}` for the path
- `{n}` for the file name without the extension
- `{e}` for the file extension including the `.`

`fn` will be called with each matched file path `file` and the destination path `dest` (with the above placeholders replaced to the actual values).

Example:
```ts
import fs from 'node:fs/promises'
import { op, gmv, gcp } from 'glops'

// mv files with glob
const myGmv = op(fs.rename)

// cp files with glob
const myGcp = op(fs.copyFile)

await gmv(['./dist/**/*.js'], '{p}{n}.cjs')

await gcp(['./dist/**/*.d.ts'], '{p}{n}.cts')
```

CLI example:
```sh
npm install -g glops
gmv ./dist/**/*.js {p}{n}.cjs
gcp ./dist/**/*.d.ts {p}{n}.cts
```

## License

[MIT License](./LICENSE)

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