diff options
Diffstat (limited to 'packages/create-astro/test/utils.js')
-rw-r--r-- | packages/create-astro/test/utils.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/packages/create-astro/test/utils.js b/packages/create-astro/test/utils.js index ff5d5dd83..56ef55605 100644 --- a/packages/create-astro/test/utils.js +++ b/packages/create-astro/test/utils.js @@ -1,3 +1,4 @@ +import fs from 'node:fs'; import { setStdout } from '../dist/index.js'; import stripAnsi from 'strip-ansi'; @@ -29,3 +30,29 @@ export function setup() { }, }; } + +const resetEmptyFixture = () => + fs.promises.rm(new URL('./fixtures/empty/tsconfig.json', import.meta.url)); +const resetNotEmptyFixture = async () => { + const packagePath = new URL('./fixtures/not-empty/package.json', import.meta.url); + const tsconfigPath = new URL('./fixtures/not-empty/tsconfig.json', import.meta.url); + + const overriddenPackageJson = Object.assign( + JSON.parse(await fs.promises.readFile(packagePath, { encoding: 'utf-8' })), + { + scripts: { + build: 'astro build', + }, + } + ); + + return Promise.all([ + fs.promises.writeFile(packagePath, JSON.stringify(overriddenPackageJson, null, 2), { + encoding: 'utf-8', + }), + fs.promises.writeFile(tsconfigPath, '{}', { encoding: 'utf-8' }), + ]); +}; + +export const resetFixtures = () => + Promise.allSettled([resetEmptyFixture(), resetNotEmptyFixture()]); |