1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const stream_1 = tslib_1.__importDefault(require("stream"));
|
5 | const humanize_list_1 = tslib_1.__importDefault(require("humanize-list"));
|
6 | const plugin_error_1 = tslib_1.__importDefault(require("plugin-error"));
|
7 | const PLUGIN_NAME = 'duplicates';
|
8 | function vinylAssertFiles() {
|
9 | const foundPaths = new Set();
|
10 | const duplicatePaths = new Set();
|
11 | return new stream_1.default.Transform({
|
12 | objectMode: true,
|
13 | transform(file, _, cb) {
|
14 | if (!file.isNull()) {
|
15 | if (foundPaths.has(file.relative)) {
|
16 | duplicatePaths.add(file.relative);
|
17 | }
|
18 | else {
|
19 | foundPaths.add(file.relative);
|
20 | }
|
21 | }
|
22 | cb(undefined, file);
|
23 | },
|
24 | flush(cb) {
|
25 | if (duplicatePaths.size !== 0) {
|
26 | this.emit('error', new plugin_error_1.default(PLUGIN_NAME, `One or more files in the build output were duplicates: ${humanize_list_1.default([...duplicatePaths])}`));
|
27 | }
|
28 | cb();
|
29 | },
|
30 | });
|
31 | }
|
32 | exports.default = vinylAssertFiles;
|