mirror of
https://github.com/cockpit-project/cockpit.git
synced 2026-11-03 21:49:50 -09:00
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Differential ShellCheck / shellcheck (push) Waiting to run
Cockpit manifests / validate-manifests (push) Waiting to run
Cockpit manifests / validate-schemas (push) Waiting to run
This got removed from the template with e51cf81cd2 ("unit tests: Don't
load cockpit.js in the qunit HTML template") but we've been deadcode
expanding it ever since. Drop it.
22 lines
925 B
JavaScript
22 lines
925 B
JavaScript
// SPDX-License-Identifier: LGPL-2.1-or-later
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
export const cockpitTestHtmlPlugin = ({ testFiles }) => ({
|
|
name: 'CockpitTestHtmlPlugin',
|
|
setup(build) {
|
|
build.onEnd(async () => {
|
|
const data = fs.readFileSync(path.resolve(import.meta.dirname, "qunit-template.html.in"), "utf8");
|
|
testFiles.forEach(file => {
|
|
const test = path.parse(file).name;
|
|
const output = data.toString()
|
|
.replaceAll("%title%", test)
|
|
.replaceAll("%script%", test + '.js');
|
|
const outdir = path.join(build.initialOptions.outdir, path.dirname(file));
|
|
const outfile = test + ".html";
|
|
|
|
fs.mkdirSync(outdir, { recursive: true });
|
|
fs.writeFileSync(path.resolve(outdir, outfile), output);
|
|
});
|
|
});
|
|
}
|
|
});
|