2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-17 19:21:29 +03:00
Files
axios/tests/module/cjs/tests/helpers/fixture.cjs
T
Jay 76794ac27a chore: update module test for full check (#7510)
* chore: add additional testing to esm and cjs smoke

* test: updated test suite to include module tests

* fix: esm test smoke import

* fix: cubic feedback

* fix: failing cjs

* fix: cjs timeout
2026-03-15 21:10:52 +02:00

33 lines
889 B
JavaScript

const fs = require('fs');
const path = require('path');
const createTempFixture = (suiteRoot, name, sourcePath, tsconfig, packageJson) => {
const tempRoot = fs.mkdtempSync(path.join(suiteRoot, `.tmp-module-${name}-`));
const source = fs.readFileSync(sourcePath, 'utf8');
fs.writeFileSync(path.join(tempRoot, 'index.ts'), source);
fs.writeFileSync(path.join(tempRoot, 'tsconfig.json'), JSON.stringify(tsconfig, null, 2));
if (packageJson) {
fs.writeFileSync(path.join(tempRoot, 'package.json'), JSON.stringify(packageJson, null, 2));
}
return tempRoot;
};
const cleanupTempFixture = (dirPath) => {
if (typeof fs.rmSync === 'function') {
fs.rmSync(dirPath, { recursive: true, force: true });
return;
}
if (fs.existsSync(dirPath)) {
fs.rmdirSync(dirPath, { recursive: true });
}
};
module.exports = {
createTempFixture,
cleanupTempFixture,
};