ngx-admin/config/helpers.js

33 lines
781 B
JavaScript
Raw Normal View History

2016-04-20 16:32:12 +03:00
/**
* @author: @AngularClass
*/
var path = require('path');
// Helper functions
var ROOT = path.resolve(__dirname, '..');
2016-04-20 16:32:12 +03:00
function hasProcessFlag(flag) {
return process.argv.join('').indexOf(flag) > -1;
}
function isWebpackDevServer() {
return process.argv[1] && !! (/webpack-dev-server$/.exec(process.argv[1]));
2016-04-20 16:32:12 +03:00
}
function root(args) {
2016-04-20 16:32:12 +03:00
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [ROOT].concat(args));
2016-04-20 16:32:12 +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
}
cb();
2016-04-20 16:32:12 +03:00
}
exports.hasProcessFlag = hasProcessFlag;
exports.isWebpackDevServer = isWebpackDevServer;
2016-04-20 16:32:12 +03:00
exports.root = root;
exports.checkNodeImport = checkNodeImport;