blob: 8d62384ec12d5313c12b38845918edf0f426ec37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import fs from "fs";
import path from 'path';
import _ from 'lodash';
const srcdir = process.env.SRCDIR || '.';
const libdir = path.resolve(srcdir, "pkg", "lib");
export const cockpitTestHtmlPlugin = ({ testFiles }) => ({
name: 'CockpitTestHtmlPlugin',
setup(build) {
build.onEnd(async () => {
const data = fs.readFileSync(path.resolve(libdir, "qunit-template.html.in"), "utf8");
testFiles.forEach(file => {
const test = path.parse(file).name;
const output = _.template(data.toString())({
title: test,
builddir: file.split("/").map(() => "../").join(""),
script: test + '.js',
});
const outdir = './qunit/' + path.dirname(file);
const outfile = test + ".html";
fs.mkdirSync(outdir, { recursive: true });
fs.writeFileSync(path.resolve(outdir, outfile), output);
});
});
}
});
|