๐Ÿ“ฆ antongolub / glob-runner

Tiny helper to search and exec js files by glob pattern

โ˜… 0 stars โ‘‚ 0 forks ๐Ÿ‘ 0 watching โš–๏ธ MIT License
glob
๐Ÿ“ฅ Clone https://github.com/antongolub/glob-runner.git
HTTPS git clone https://github.com/antongolub/glob-runner.git
SSH git clone git@github.com:antongolub/glob-runner.git
CLI gh repo clone antongolub/glob-runner
renovate[bot] renovate[bot] chore(deps): update github/codeql-action action to v4 (#48) 9eb01fe 1 months ago ๐Ÿ“ History
๐Ÿ“‚ master View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ CHANGELOG.md
๐Ÿ“„ LICENSE
๐Ÿ“„ package.json
๐Ÿ“„ README.md
๐Ÿ“„ renovate.json
๐Ÿ“„ yarn.lock
๐Ÿ“„ README.md

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

  • https://github.com/fahad19/glob-run

License

MIT