Skip to content

Commit d0a0358

Browse files
committed
guarded against duplicate targets
as suggested by @tloist
1 parent 19e60f0 commit d0a0358

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/index.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,16 @@ module.exports = {
1111
};
1212

1313
function faucetJS(config, assetManager, { browsers, compact, sourcemaps } = {}) {
14+
let targets = new Set();
1415
let bundlers = config.map(bundleConfig => makeBundler(bundleConfig,
15-
assetManager, { browsers, compact, sourcemaps }));
16+
assetManager, { browsers, compact, sourcemaps, targets }));
1617

1718
return filepaths => Promise.all(bundlers.
1819
map(bundler => bundler(filepaths)));
1920
}
2021

21-
function makeBundler(bundleConfig, assetManager, { browsers, compact, sourcemaps } = {}) {
22+
function makeBundler(bundleConfig, assetManager,
23+
{ browsers, compact, sourcemaps, targets }) {
2224
// NB: bundle-specific configuration can override global options
2325
let config = Object.assign({ sourcemaps, compact }, bundleConfig, { browsers });
2426
if(!compact) {
@@ -35,6 +37,10 @@ function makeBundler(bundleConfig, assetManager, { browsers, compact, sourcemaps
3537
let { resolvePath } = assetManager;
3638
entryPoint = resolvePath(entryPoint);
3739
target = resolvePath(target, { enforceRelative: true });
40+
if(targets.has(target)) {
41+
throw new Error(`duplicate target: ${target}`);
42+
}
43+
targets.add(target);
3844
let bundle = new Bundle(entryPoint, target, config, { browsers });
3945

4046
let writer = makeWriter(bundle, assetManager);

0 commit comments

Comments
 (0)