"use strict";

const fs = require("fs");

module.exports = {
	afterExecute(options) {
		const outputPath = options.output.path;
		const files = fs.readdirSync(outputPath);

		const expected = ["bundle0.js", "my-custom-worker.js"];
		const intersection = expected.filter((value) => files.includes(value));

		if (intersection.length !== 2) {
			throw new Error(
				`Not all files were generated by webpack, expected ${JSON.stringify(expected)}, got ${JSON.stringify(files)}`
			);
		}
	}
};
