Thanks to visit codestin.com
Credit goes to github.com

Skip to content

antongolub/glob-runner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

85 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Tiny helper to search and exec js files by glob pattern

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors 3

  •  
  •  
  •