Skip to content

Commit 5459b93

Browse files
committed
Refactor local make_baseline script
1 parent 6b23e4c commit 5459b93

2 files changed

Lines changed: 17 additions & 27 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
"mathjax3chtml": "node devtools/test_dashboard/server.mjs --mathjax3chtml",
5555
"strict": "node devtools/test_dashboard/server.mjs --strict",
5656
"start": "node devtools/test_dashboard/server.mjs",
57-
"baseline": "node test/image/make_baseline.js",
57+
"baseline": "node test/image/make_baseline.mjs",
5858
"noci-baseline": "npm run cibuild && ./tasks/noci_test.sh image && git checkout dist && echo 'Please do not commit unless the change was expected!'",
5959
"preversion": "check-node-version --node 18 --npm 10 && npm-link-check && npm ls --prod --all",
6060
"version": "npm run build && git add -A lib dist build src/version.js",
Lines changed: 16 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
var minimist = require('minimist');
2-
var path = require('path');
3-
var spawn = require('child_process').spawn;
1+
import { spawn } from 'child_process';
2+
import { readFileSync } from 'fs';
3+
import minimist from 'minimist';
4+
import path from 'path';
5+
import getMockList from './assets/get_mock_list.js';
46

5-
var getMockList = require('./assets/get_mock_list');
7+
const collections = JSON.parse(readFileSync(new URL('./compare_pixels_collections.json', import.meta.url)));
68

79
/**
810
* Baseline image generation script.
@@ -35,48 +37,36 @@ var getMockList = require('./assets/get_mock_list');
3537
*
3638
*/
3739

38-
var argv = minimist(process.argv.slice(2), {});
40+
const argv = minimist(process.argv.slice(2), {});
3941

40-
var allMockList = [];
41-
var mathjax3, b64;
42-
argv._.forEach(function (pattern) {
42+
let allMockList = [];
43+
let mathjax3, b64;
44+
argv._.forEach((pattern) => {
4345
if (pattern === 'b64') {
4446
b64 = true;
4547
} else if (pattern === 'mathjax3') {
4648
mathjax3 = true;
4749
} else {
48-
var mockList = getMockList(pattern);
50+
const mockList = getMockList(pattern);
4951

5052
if (mockList.length === 0) {
51-
throw new Error('No mocks found with pattern ' + pattern);
53+
throw new Error(`No mocks found with pattern ${pattern}`);
5254
}
5355

5456
allMockList = allMockList.concat(mockList);
5557
}
5658
});
5759

58-
if (mathjax3) {
59-
allMockList = [
60-
'legend_mathjax_title_and_items',
61-
'mathjax',
62-
'parcats_grid_subplots',
63-
'table_latex_multitrace_scatter',
64-
'table_plain_birds',
65-
'table_wrapped_birds',
66-
'ternary-mathjax',
67-
'ternary-mathjax-title-place-subtitle'
68-
];
69-
}
70-
60+
if (mathjax3) allMockList = collections.mathjax3;
7161
if (allMockList.length) console.log(allMockList);
7262
console.log('Please wait for the process to complete.');
7363

74-
var p = spawn('python3', [
64+
const p = spawn('python3', [
7565
path.join('test', 'image', 'make_baseline.py'),
76-
(mathjax3 ? 'mathjax3' : '') + (b64 ? 'b64' : '') + '= ' + allMockList.join(' ')
66+
`${mathjax3 ? 'mathjax3' : ''}${b64 ? 'b64' : ''}= ${allMockList.join(' ')}`
7767
]);
7868
try {
79-
p.stdout.on('data', function (data) {
69+
p.stdout.on('data', (data) => {
8070
console.log(data.toString());
8171
});
8272
} catch (e) {

0 commit comments

Comments
 (0)