1 | var through = require("through2");
|
2 | var omit = require("lodash/omit");
|
3 | var clone = require("lodash/clone");
|
4 | var assign = require("lodash/assign");
|
5 |
|
6 | module.exports = function(options) {
|
7 | return through.obj(function(data, enc, next) {
|
8 | try {
|
9 | next(null, options.target ? adjustBundlesPath(data, options) : data);
|
10 | } catch (err) {
|
11 | next(err);
|
12 | }
|
13 | });
|
14 | };
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | function adjustBundlesPath(data, options) {
|
28 | var path = require("path");
|
29 | var configuration = clone(data.configuration);
|
30 |
|
31 | var bundlesPath = configuration.bundlesPath;
|
32 | Object.defineProperty(configuration, "bundlesPath", {
|
33 | configurable: true,
|
34 | get: function() {
|
35 | return path.join(bundlesPath, options.target);
|
36 | }
|
37 | });
|
38 |
|
39 | return assign({}, omit(data, ["configuration"]), {
|
40 | configuration: configuration
|
41 | });
|
42 | }
|