UNPKG

webpack-subresource-integrity

Version:
70 lines 3.13 kB
"use strict"; /** * Copyright (c) 2015-present, Waysact Pty Ltd * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const cross_spawn_1 = __importDefault(require("cross-spawn")); const path_1 = require("path"); const rimraf_1 = __importDefault(require("rimraf")); const util_1 = require("util"); jest.unmock("html-webpack-plugin"); jest.setTimeout(120000); const rimrafPromise = (0, util_1.promisify)(rimraf_1.default); (0, fs_1.readdirSync)("../examples/").forEach((example) => { test.concurrent(example, () => __awaiter(void 0, void 0, void 0, function* () { const exampleDirectory = (0, path_1.join)("../examples", example); yield rimrafPromise((0, path_1.join)(exampleDirectory, "dist")); yield new Promise((resolve, reject) => { var _a, _b; const stdout = []; const stderr = []; const yarn = (0, cross_spawn_1.default)("yarn", process.env["USE_COVERAGE"] ? [ "nyc", "--instrument=false", "--cwd=../..", "--clean=false", "--source-map=false", "webpack", "--no-stats", ] : ["webpack", "--no-stats"], { cwd: exampleDirectory, stdio: ["ignore", "pipe", "pipe"], }); (_a = yarn.stdout) === null || _a === void 0 ? void 0 : _a.on("data", (data) => { stdout.push(data); }); (_b = yarn.stderr) === null || _b === void 0 ? void 0 : _b.on("data", (data) => { stderr.push(data); }); yarn.on("exit", (code) => { if (code === 0) { resolve(); } else { reject(new Error(`child process exited with code ${code}: ${stdout.join("")} ${stderr.join("")}`)); } }); yarn.on("error", reject); }); yield new Promise((resolve) => setTimeout(resolve, 0)); })); }); //# sourceMappingURL=examples.test.js.map