2016-04-20 16:32:12 +03:00
|
|
|
/**
|
|
|
|
|
* @author: @AngularClass
|
|
|
|
|
*/
|
|
|
|
|
var path = require('path');
|
|
|
|
|
|
|
|
|
|
// Helper functions
|
2016-07-28 13:38:22 +03:00
|
|
|
var ROOT = path.resolve(__dirname, '..');
|
2016-04-20 16:32:12 +03:00
|
|
|
|
|
|
|
|
function hasProcessFlag(flag) {
|
|
|
|
|
return process.argv.join('').indexOf(flag) > -1;
|
|
|
|
|
}
|
|
|
|
|
|
2016-07-28 13:38:22 +03:00
|
|
|
function isWebpackDevServer() {
|
|
|
|
|
return process.argv[1] && !! (/webpack-dev-server$/.exec(process.argv[1]));
|
2016-04-20 16:32:12 +03:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 13:38:22 +03:00
|
|
|
function root(args) {
|
2016-04-20 16:32:12 +03:00
|
|
|
args = Array.prototype.slice.call(arguments, 0);
|
2016-07-28 13:38:22 +03:00
|
|
|
return path.join.apply(path, [ROOT].concat(args));
|
2016-04-20 16:32:12 +03:00
|
|
|
}
|
|
|
|
|
|
2016-07-28 13:38:22 +03:00
|
|
|
function checkNodeImport(context, request, cb) {
|
|
|
|
|
if (!path.isAbsolute(request) && request.charAt(0) !== '.') {
|
|
|
|
|
cb(null, 'commonjs ' + request); return;
|
2016-04-20 16:32:12 +03:00
|
|
|
}
|
2016-07-28 13:38:22 +03:00
|
|
|
cb();
|
2016-04-20 16:32:12 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exports.hasProcessFlag = hasProcessFlag;
|
2016-07-28 13:38:22 +03:00
|
|
|
exports.isWebpackDevServer = isWebpackDevServer;
|
2016-04-20 16:32:12 +03:00
|
|
|
exports.root = root;
|
2016-07-28 13:38:22 +03:00
|
|
|
exports.checkNodeImport = checkNodeImport;
|