mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
c8f5fa35c4
* feat: add git init step * fix: update unit tests * feat: simplify next steps for copy pasteability * docs: add clarifying comment on test stdin spoofing * docs: remove "empty" from git repo message * fix: update git step text for test * fix: remove redundant --dryrun flag * refactor: simplify next steps with && * chore: changeset
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import { execa } from 'execa';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname } from 'path';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
export const testDir = dirname(__filename);
|
|
export const timeout = 5000;
|
|
|
|
const createAstroError = new Error(
|
|
'Timed out waiting for create-astro to respond with expected output.'
|
|
);
|
|
|
|
export function promiseWithTimeout(testFn) {
|
|
return new Promise((resolve, reject) => {
|
|
const timeoutEvent = setTimeout(() => {
|
|
reject(createAstroError);
|
|
}, timeout);
|
|
function resolver() {
|
|
clearTimeout(timeoutEvent);
|
|
resolve();
|
|
}
|
|
testFn(resolver);
|
|
});
|
|
}
|
|
|
|
export const PROMPT_MESSAGES = {
|
|
directory: 'Where would you like to create your app?',
|
|
template: 'Which app template would you like to use?',
|
|
install: (pkgManager) => `Would you like us to run "${pkgManager} install?"`,
|
|
astroAdd: (astroAddCommand = 'npx astro@latest add --yes') =>
|
|
`Run "${astroAddCommand}?" This lets you optionally add component frameworks (ex. React), CSS frameworks (ex. Tailwind), and more.`,
|
|
git: 'Initialize a git repository?',
|
|
};
|
|
|
|
export function setup(args = []) {
|
|
const { stdout, stdin } = execa('../create-astro.mjs', [...args, '--dryrun'], { cwd: testDir });
|
|
return {
|
|
stdin,
|
|
stdout,
|
|
};
|
|
}
|