kentcdodds / nps-utils

Utilities for http://npm.im/nps (npm-package-scripts)
https://doclets.io/kentcdodds/nps-utils/master
MIT License
101 stars 23 forks source link

Support glob-like patterns? #7

Closed kentcdodds closed 6 years ago

kentcdodds commented 7 years ago

Basically so people transitioning from npm-run-all can have something for their scripts that are like: npm-run-all test:*

Could be something like:

runAll('test.*') // runs test.client and test.server (but not test.server.watch)
runAll('build.**') // runs build.main, build.umd, and build.umd.min
runAll('lint.* --cache') // runs "lint.client --cache" and "lint.server --cache"
runAllConcurrent('validate.*') // runs validate.lint, validate.test, and validate.build concurrently

By runs ___ I don't mean it actually runs those scripts, it simply returns a script that would run those things :)

Anyone wanna take this one? The biggest challenge will be figuring out what the scripts are. Thinking that it may be better to support this in nps itself actually... Thoughts welcome!

kentcdodds commented 7 years ago

After thinking about it more. I think that I'd prefer this live in nps-utils. And I'm thinking that we could do something like:

const {mergeScripts, runAll} = require('nps-utils')

const npsConfig = {
  scripts: {/* scripts */},
}
mergeScripts(npsConfig, {
  test: runAll('test.*'),
  validate: runAllConcurrent('validate.*'),
})
module.exports = npsConfig

There would have to be some fancy logic to make this work, but I think that's the best API.