1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const path_1 = tslib_1.__importDefault(require("path"));
|
5 | const stream_1 = tslib_1.__importDefault(require("stream"));
|
6 | const humanize_list_1 = tslib_1.__importDefault(require("humanize-list"));
|
7 | const plugin_error_1 = tslib_1.__importDefault(require("plugin-error"));
|
8 | const PLUGIN_NAME = 'assert-files';
|
9 | function vinylAssertFiles(expected) {
|
10 | const expectedPaths = new Set(expected.map(path_1.default.normalize));
|
11 | return new stream_1.default.Transform({
|
12 | objectMode: true,
|
13 | transform(file, _, cb) {
|
14 | if (!file.isNull())
|
15 | expectedPaths.delete(file.relative);
|
16 | cb(undefined, file);
|
17 | },
|
18 | flush(cb) {
|
19 | if (expectedPaths.size !== 0) {
|
20 | this.emit('error', new plugin_error_1.default(PLUGIN_NAME, `One or more required files do not exist in the project: ${humanize_list_1.default([...expectedPaths])}`));
|
21 | }
|
22 | cb();
|
23 | },
|
24 | });
|
25 | }
|
26 | exports.default = vinylAssertFiles;
|