2.1.1 • Published 10 months ago

glob-runner v2.1.1

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

glob-runner

Tiny helper to search and exec js files by glob pattern with optional Node.js version restrictions

CI Maintainability Test Coverage npm (tag)

Install

yarn add glob-runner -D

Usage

JS/TS API

import { run } from 'glob-runner'

await run({
  pattern: 'src/test/**/*.it.js', // pattern to load
  cwd: '/foo/bar',                // process dir         process.cwd()
  cb: () => {},                   // handler             noop
  nodeVersion: '20.0.0',          // required nodejs     process.version
  parallel: true,                 // run in parallel     false
  silent: true,                   // suppress logs       false
  glob: fg,                       // glob API provider   fast-glob
})

// Skipped /gh/glob-runner/src/test/js/index.cjs.it.js. v16.7.0 does not satisfy ^12.20.0
// Loading /gh/glob-runner/src/test/js/index.mjs.it.js...
// Done

CLI

glob-runner src/test/**/*.it.js
# Loading /gh/glob-runner/src/test/js/index.mjs.it.js...
# Done

Node engine

Any running script can define its own Node.js engine requirements through special annotation at the beginning of the file:

// node-engine ^12.20.0 || ^14.13.1 || >=16.0.0

If current the runtime does not match the pattern, invocation will be skipped. This feature might be useful for writing integration tests for several Node.js versions. For example, require API with node: prefix needs v16.0.0+, so your script may look like:

// node-engine >=16.0.0

const {read} = require('node:fs')

read('/foo/bar')

Alternatives

License

MIT

2.1.1

10 months ago

2.0.2

12 months ago

2.0.4

12 months ago

2.1.0

12 months ago

2.0.1

12 months ago

2.0.0

12 months ago

1.0.6

2 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago