2016-06-03 22:08:03 +02:00
|
|
|
const path = require('path')
|
|
|
|
|
2017-01-13 12:16:00 +01:00
|
|
|
// Helper functions
|
2016-06-03 22:08:03 +02:00
|
|
|
const ROOT = path.resolve(__dirname, '..')
|
2017-01-13 12:16:00 +01:00
|
|
|
const EVENT = process.env.npm_lifecycle_event || ''
|
2016-06-03 22:08:03 +02:00
|
|
|
|
|
|
|
function hasProcessFlag (flag) {
|
|
|
|
return process.argv.join('').indexOf(flag) > -1
|
|
|
|
}
|
|
|
|
|
2017-01-13 12:16:00 +01:00
|
|
|
function hasNpmFlag (flag) {
|
|
|
|
return EVENT.includes(flag)
|
|
|
|
}
|
|
|
|
|
2016-09-06 22:40:57 +02:00
|
|
|
function isWebpackDevServer () {
|
|
|
|
return process.argv[1] && !!(/webpack-dev-server$/.exec(process.argv[1]))
|
|
|
|
}
|
|
|
|
|
2016-06-03 22:08:03 +02:00
|
|
|
function root (args) {
|
|
|
|
args = Array.prototype.slice.call(arguments, 0)
|
|
|
|
return path.join.apply(path, [ROOT].concat(args))
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.hasProcessFlag = hasProcessFlag
|
2017-01-13 12:16:00 +01:00
|
|
|
exports.hasNpmFlag = hasNpmFlag
|
2016-09-06 22:40:57 +02:00
|
|
|
exports.isWebpackDevServer = isWebpackDevServer
|
2016-06-03 22:08:03 +02:00
|
|
|
exports.root = root
|