mirror of
https://github.com/withastro/astro.git
synced 2024-12-23 21:53:55 -05:00
507cd5c868
* chore: remove complex install step test * chore: changeset
37 lines
933 B
JavaScript
37 lines
933 B
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 new project?',
|
|
template: 'Which template would you like to use?',
|
|
};
|
|
|
|
export function setup(args = []) {
|
|
const { stdout, stdin } = execa('../create-astro.mjs', [...args, '--dryrun'], { cwd: testDir });
|
|
return {
|
|
stdin,
|
|
stdout,
|
|
};
|
|
}
|