0.0.4 • Published 11 months ago

glops v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

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

npm install glops
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.

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:

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:

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

License

MIT License

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago