|
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'; |
4 | 6 |
|
5 | | -var getMockList = require('./assets/get_mock_list'); |
| 7 | +const collections = JSON.parse(readFileSync(new URL('./compare_pixels_collections.json', import.meta.url))); |
6 | 8 |
|
7 | 9 | /** |
8 | 10 | * Baseline image generation script. |
@@ -35,48 +37,36 @@ var getMockList = require('./assets/get_mock_list'); |
35 | 37 | * |
36 | 38 | */ |
37 | 39 |
|
38 | | -var argv = minimist(process.argv.slice(2), {}); |
| 40 | +const argv = minimist(process.argv.slice(2), {}); |
39 | 41 |
|
40 | | -var allMockList = []; |
41 | | -var mathjax3, b64; |
42 | | -argv._.forEach(function (pattern) { |
| 42 | +let allMockList = []; |
| 43 | +let mathjax3, b64; |
| 44 | +argv._.forEach((pattern) => { |
43 | 45 | if (pattern === 'b64') { |
44 | 46 | b64 = true; |
45 | 47 | } else if (pattern === 'mathjax3') { |
46 | 48 | mathjax3 = true; |
47 | 49 | } else { |
48 | | - var mockList = getMockList(pattern); |
| 50 | + const mockList = getMockList(pattern); |
49 | 51 |
|
50 | 52 | if (mockList.length === 0) { |
51 | | - throw new Error('No mocks found with pattern ' + pattern); |
| 53 | + throw new Error(`No mocks found with pattern ${pattern}`); |
52 | 54 | } |
53 | 55 |
|
54 | 56 | allMockList = allMockList.concat(mockList); |
55 | 57 | } |
56 | 58 | }); |
57 | 59 |
|
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; |
71 | 61 | if (allMockList.length) console.log(allMockList); |
72 | 62 | console.log('Please wait for the process to complete.'); |
73 | 63 |
|
74 | | -var p = spawn('python3', [ |
| 64 | +const p = spawn('python3', [ |
75 | 65 | path.join('test', 'image', 'make_baseline.py'), |
76 | | - (mathjax3 ? 'mathjax3' : '') + (b64 ? 'b64' : '') + '= ' + allMockList.join(' ') |
| 66 | + `${mathjax3 ? 'mathjax3' : ''}${b64 ? 'b64' : ''}= ${allMockList.join(' ')}` |
77 | 67 | ]); |
78 | 68 | try { |
79 | | - p.stdout.on('data', function (data) { |
| 69 | + p.stdout.on('data', (data) => { |
80 | 70 | console.log(data.toString()); |
81 | 71 | }); |
82 | 72 | } catch (e) { |
|
0 commit comments