2
1

helpers.js 674 B

123456789101112131415161718192021222324252627
  1. const path = require('path')
  2. // Helper functions
  3. const ROOT = path.resolve(__dirname, '..')
  4. const EVENT = process.env.npm_lifecycle_event || ''
  5. function hasProcessFlag (flag) {
  6. return process.argv.join('').indexOf(flag) > -1
  7. }
  8. function hasNpmFlag (flag) {
  9. return EVENT.includes(flag)
  10. }
  11. function isWebpackDevServer () {
  12. return process.argv[1] && !!(/webpack-dev-server$/.exec(process.argv[1]))
  13. }
  14. function root (args) {
  15. args = Array.prototype.slice.call(arguments, 0)
  16. return path.join.apply(path, [ROOT].concat(args))
  17. }
  18. exports.hasProcessFlag = hasProcessFlag
  19. exports.hasNpmFlag = hasNpmFlag
  20. exports.isWebpackDevServer = isWebpackDevServer
  21. exports.root = root