Chart.js/types/tests/autogen.js
Jukka Kurkela 3ed94559dd
Add missing typings of helpers, add automatic test (#9570)
* Add missing typings of helpers, add automatic test

* Add error handling to autogen.js
2021-09-01 20:27:26 -04:00

23 lines
576 B
JavaScript

import * as fs from 'fs';
import * as path from 'path';
import * as helpers from '../../src/helpers/index.js';
let fd;
try {
const fn = path.resolve(__dirname, 'autogen_helpers.ts');
fd = fs.openSync(fn, 'w+');
fs.writeSync(fd, 'import * as helpers from \'../helpers\';\n\n');
fs.writeSync(fd, 'const testKeys = [];\n');
for (const key of Object.keys(helpers)) {
if (key[0] !== '_' && typeof helpers[key] === 'function') {
fs.writeSync(fd, `testKeys.push(helpers.${key});\n`);
}
}
} finally {
if (fd !== undefined) {
fs.closeSync(fd);
}
}