js-vitest template

small update for fix-jest-dom
This commit is contained in:
Alex Lohr
2022-03-14 21:39:38 +01:00
parent a29501c437
commit 5930402172
13 changed files with 1942 additions and 9 deletions
+9 -9
View File
@@ -2,17 +2,17 @@ import fs from 'fs';
import path from 'path';
const typesPath = path.resolve('node_modules', '@types', 'testing-library__jest-dom', 'index.d.ts');
const refMatcher = /[\r\n]+\/\/\/ <reference types="jest" \/>/;
fs.readFile(typesPath, 'utf8', (err, data) => {
if (err) throw err;
let lines = data.split('\n');
if (lines[8] === '/// <reference types="jest" />') {
lines = lines.slice(0, 8).concat(lines.slice(9));
}
fs.writeFile(typesPath, lines.join('\n'), 'utf8', function(err) {
if (err) throw err;
});
fs.writeFile(
typesPath,
data.replace(refMatcher, ''),
'utf8',
function(err) {
if (err) throw err;
}
);
});