zambezi / ez-build

Zambezi build tool
MIT License
2 stars 1 forks source link

Execute arbitrary command on successful interactive build #50

Closed mstade closed 6 years ago

mstade commented 7 years ago

Description

These changes allow a user to run an arbitrary command on the successful result of an interactive build. This is useful to for instance kick off tests every time a watched source file changes. Consider the following collection of scripts:

{
  "scripts": {
    "build": "ez-build",
    "test": "tape -r source-map-support/register test/*.test.js",
    "test:dev": "npm run -s build -- --interactive \"npm run -s test | tap-dot\""
  }
}

In this, the test:dev script kicks off the build script, which simply builds the project with default settings, but it also enables interactive mode and tells ez-build to run the command npm run -s test | tap-dot whenever it successfully builds a file. This has the effect of running all tests whenever a source file changes and is successfully built.

Motivation and Context

It's a common use case to run some command whenever a build is successful, typically running tests or the likes to ensure changes don't cause unwanted failures. It's really only relevant to do this on successful builds, since broken files won't run anyway.

How Was This Tested?

CLI tests were added to test against a project fixture, and unit tests were added to ensure we parse the CLI option properly.

Types of changes

Checklist:

codecov-io commented 7 years ago

Codecov Report

Merging #50 into master will increase coverage by 0.14%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #50      +/-   ##
=========================================
+ Coverage   95.06%   95.2%   +0.14%     
=========================================
  Files          15      15              
  Lines         324     334      +10     
=========================================
+ Hits          308     318      +10     
  Misses         16      16
Impacted Files Coverage Δ
src/cli/opts.js 100% <ø> (ø) :arrow_up:
src/main.js 97.32% <100%> (+0.26%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4e72767...e97439d. Read the comment docs.