21b30c94f4
- The current huge test utilities file is really hard to reason about - It is so big we have no idea what's in it anymore - It's also full of terrible code we want to rework - Splitting it down into smaller pieces makes it easier to see which are the worst bits!
34 lines
978 B
JavaScript
34 lines
978 B
JavaScript
const fs = require('fs-extra');
|
|
const path = require('path');
|
|
|
|
/**
|
|
* Set up the redirects file with the extension you want.
|
|
*/
|
|
module.exports.setupFile = (contentFolderForTests, ext) => {
|
|
const yamlPath = path.join(contentFolderForTests, 'data', 'redirects.yaml');
|
|
const jsonPath = path.join(contentFolderForTests, 'data', 'redirects.json');
|
|
|
|
if (ext === '.json') {
|
|
if (fs.existsSync(yamlPath)) {
|
|
fs.removeSync(yamlPath);
|
|
}
|
|
fs.copySync(path.join(__dirname, 'fixtures', 'data', 'redirects.json'), jsonPath);
|
|
}
|
|
|
|
if (ext === '.yaml') {
|
|
if (fs.existsSync(jsonPath)) {
|
|
fs.removeSync(jsonPath);
|
|
}
|
|
fs.copySync(path.join(__dirname, 'fixtures', 'data', 'redirects.yaml'), yamlPath);
|
|
}
|
|
|
|
if (ext === null) {
|
|
if (fs.existsSync(yamlPath)) {
|
|
fs.removeSync(yamlPath);
|
|
}
|
|
if (fs.existsSync(jsonPath)) {
|
|
fs.removeSync(jsonPath);
|
|
}
|
|
}
|
|
};
|