Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

config-util.js 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. 'use strict'
  2. const path = require('path')
  3. const findUp = require('find-up')
  4. const Yargs = require('yargs/yargs')
  5. const { setupOptions } = require('./commands/helpers')
  6. const processArgs = require('./process-args')
  7. const { loadNycConfig } = require('@istanbuljs/load-nyc-config')
  8. async function guessCWD (cwd) {
  9. cwd = cwd || process.env.NYC_CWD || process.cwd()
  10. const pkgPath = await findUp('package.json', { cwd })
  11. if (pkgPath) {
  12. cwd = path.dirname(pkgPath)
  13. }
  14. return cwd
  15. }
  16. async function processConfig (cwd) {
  17. cwd = await guessCWD(cwd)
  18. const yargs = Yargs([])
  19. .usage('$0 [command] [options]')
  20. .usage('$0 [options] [bin-to-instrument]')
  21. .showHidden(false)
  22. setupOptions(yargs, null, cwd)
  23. yargs
  24. .example('$0 npm test', 'instrument your tests with coverage')
  25. .example('$0 --require @babel/register npm test', 'instrument your tests with coverage and transpile with Babel')
  26. .example('$0 report --reporter=text-lcov', 'output lcov report after running your tests')
  27. .epilog('visit https://git.io/vHysA for list of available reporters')
  28. .boolean('h')
  29. .boolean('version')
  30. .help(false)
  31. .version(false)
  32. const instrumenterArgs = processArgs.hideInstrumenteeArgs()
  33. // This yargs.parse must come before any options that exit post-hoc
  34. const childArgs = processArgs.hideInstrumenterArgs(yargs.parse(process.argv.slice(2)))
  35. const config = await loadNycConfig(yargs.parse(instrumenterArgs))
  36. yargs
  37. .config(config)
  38. .help('h')
  39. .alias('h', 'help')
  40. .version()
  41. .command(require('./commands/check-coverage'))
  42. .command(require('./commands/instrument'))
  43. .command(require('./commands/report'))
  44. .command(require('./commands/merge'))
  45. return {
  46. get argv () {
  47. return yargs.parse(instrumenterArgs)
  48. },
  49. childArgs,
  50. yargs
  51. }
  52. }
  53. module.exports = processConfig