Skip to content

Latest commit

 

History

History
51 lines (38 loc) · 1.11 KB

instrument.md

File metadata and controls

51 lines (38 loc) · 1.11 KB

esnext-coverage instrument

Usage: instrument [options] [file]

instruments code

Options:

  -h, --help             output usage information
  -o, --out-file [file]  write instrumented code to a file

Examples

Instrument a file and write output to stdout:

esnext-coverage instrument foo.js

Take code from stdin, instrument it, and write output to stdout:

cat foo.js | esnext-coverage instrument

Instrument a file and write output to a file in existing directory:

esnext-coverage instrument foo.js > foo.instrumented.js

Instrument a file and write output to a file in a new directory. Intermediate directories will be created as required (same as mkdir -p):

esnext-coverage instrument foo.js -o a/b/c/foo.instrumented.js

Instrument multiple files:

find src -name '*.js' -type f | \
  while IFS= read -r file; do
    esnext-coverage instrument "$file" -o ${file/src/dest}
  done

A simpler way to instrument multiple files (requires globstar option and bash 4):

for file in src/{,**/}*.js; do
  esnext-coverage instrument "$file" -o ${file/src/dest}
done