forked from PatrickJS/PatrickJS-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhelpers.js
More file actions
37 lines (31 loc) · 1014 Bytes
/
helpers.js
File metadata and controls
37 lines (31 loc) · 1014 Bytes
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
29
30
31
32
33
34
35
36
37
var path = require('path');
var zlib = require('zlib');
var validateWebpackConfig = require('webpack-validator');
// Helper functions
exports.validateWebpackConfig = validateWebpackConfig;
exports.validate = validateWebpackConfig;
function gzipMaxLevel(buffer, callback) {
return zlib['gzip'](buffer, {level: 9}, callback)
}
exports.gzipMaxLevel = gzipMaxLevel;
function root(args) {
args = Array.prototype.slice.call(arguments, 0);
return path.join.apply(path, [__dirname].concat(args));
}
exports.root = root;
function rootNode(args) {
args = Array.prototype.slice.call(arguments, 0);
return root.apply(path, ['node_modules'].concat(args));
}
exports.rootNode = rootNode;
function prependExt(extensions, args) {
args = args || [];
if (!Array.isArray(args)) { args = [args] }
return extensions.reduce(function(memo, val) {
return memo.concat(val, args.map(function(prefix) {
return prefix + val
}));
}, ['']);
}
exports.prependExt = prependExt;
exports.prepend = prependExt;