Skip to content

Commit

Permalink
package.json: replace single lodash user to a simple string replace
Browse files Browse the repository at this point in the history
lodash is a quite big module (4.9M) for only one simple test loader
where it uses only the template function.

We will still have lodash in our `node_modules` sadly, as
@patternfly/react-table imports it. Hopefully PatternFly can in the
future move to es-toolkit once it has implemented all of required lodash
functions.
  • Loading branch information
jelly authored and martinpitt committed Jul 26, 2024
1 parent 85e38aa commit 01b9c5e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion node_modules
Submodule node_modules updated 1100 files
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"glob": "7.2.3",
"htmlparser": "1.7.7",
"jed": "1.1.1",
"lodash": "4.17.21",
"qunit": "2.21.0",
"qunit-tap": "1.5.1",
"sass": "1.77.6",
Expand Down
10 changes: 3 additions & 7 deletions pkg/lib/esbuild-test-html-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import fs from 'node:fs';
import path from 'node:path';
import process from 'node:process';

import _ from 'lodash';

const srcdir = process.env.SRCDIR || '.';
const libdir = path.resolve(srcdir, "pkg", "lib");

Expand All @@ -14,11 +12,9 @@ export const cockpitTestHtmlPlugin = ({ testFiles }) => ({
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 builddir = file.split("/").map(() => "../").join("");
const output = data.toString().replace("%title%", test).replace("%builddir%", builddir)
.replace("%script%", test + '.js');
const outdir = './qunit/' + path.dirname(file);
const outfile = test + ".html";

Expand Down
6 changes: 3 additions & 3 deletions pkg/lib/qunit-template.html.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
<head>
<meta charset="utf-8" />
<title><%= title %></title>
<link rel="stylesheet" href="<%= title %>.css" type="text/css" />
<script src="<%= builddir %>dist/base1/cockpit.js"></script>
<script src="<%= script %>"></script>
<link rel="stylesheet" href="%title%.css" type="text/css" />
<script src="%builddir%dist/base1/cockpit.js"></script>
<script src="%script%"></script>
</head>
<body class="pf-v5-m-tabular-nums">
<h1 id="qunit-header"><%= title %></h1>
Expand Down

0 comments on commit 01b9c5e

Please sign in to comment.