| 9 | * @param file The file to move |
| 10 | */ |
| 11 | export default async function moveFile(file: string) { |
| 12 | const buffer = await fsp.readFile(file); |
| 13 | const inputFixture = yaml.load(buffer.toString()) as TestCaseFixture; |
| 14 | const parent = path.dirname(file); |
| 15 | if (path.basename(parent) !== "surroundingPair") { |
| 16 | return; |
| 17 | } |
| 18 | const childDirName = |
| 19 | inputFixture.languageId === "plaintext" |
| 20 | ? "textual" |
| 21 | : `parseTree/${inputFixture.languageId}`; |
| 22 | const childDir = path.join(parent, childDirName); |
| 23 | await mkdir(childDir, { recursive: true }); |
| 24 | const outputPath = path.join(childDir, path.basename(file)); |
| 25 | // console.log(`${file} => ${outputPath}`); |
| 26 | await rename(file, outputPath); |
| 27 | } |