summaryrefslogtreecommitdiff
path: root/packages/create-astro/test/utils.js
diff options
context:
space:
mode:
authorGravatar Phumrapee Limpianchop <git@rayriffy.com> 2023-10-24 05:14:33 +0700
committerGravatar GitHub <noreply@github.com> 2023-10-23 17:14:33 -0500
commitce807a2bfef325683bfdb01065a73c4e2b0a5fe5 (patch)
tree31c8a8bdaad2af2e239d364342e40b9097a36498 /packages/create-astro/test/utils.js
parente3c18be5d09cd46e6ba1c00171db7eab6ae93d6f (diff)
downloadastro-ce807a2bfef325683bfdb01065a73c4e2b0a5fe5.tar.gz
astro-ce807a2bfef325683bfdb01065a73c4e2b0a5fe5.tar.zst
astro-ce807a2bfef325683bfdb01065a73c4e2b0a5fe5.zip
feat(create-astro): automatically configure `astro check` (#8853)
Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
Diffstat (limited to 'packages/create-astro/test/utils.js')
-rw-r--r--packages/create-astro/test/utils.js27
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()]);