Blame view

config/helpers.js 679 Bytes
05b0b5d8   Yarik   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  var path = require('path');
  
  const EVENT = process.env.npm_lifecycle_event || '';
  
  // Helper functions
  var ROOT = path.resolve(__dirname, '..');
  
  function hasProcessFlag(flag) {
    return process.argv.join('').indexOf(flag) > -1;
  }
  
  function hasNpmFlag(flag) {
    return EVENT.includes(flag);
  }
  
  function isWebpackDevServer() {
    return process.argv[1] && !! (/webpack-dev-server/.exec(process.argv[1]));
  }
  
  function root(args) {
    args = Array.prototype.slice.call(arguments, 0);
    return path.join.apply(path, [ROOT].concat(args));
  }
  
  exports.hasProcessFlag = hasProcessFlag;
  exports.hasNpmFlag = hasNpmFlag;
  exports.isWebpackDevServer = isWebpackDevServer;
  exports.root = root;