Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Jan 9, 2025
1 parent 47fcd1b commit 4593741
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions scripts/test-package-manager.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -124,30 +124,35 @@ async function fixTSConfig(projectDir) {
writeFileSync(tsconfigPath, JSON.stringify(json, null, 2));
}

async function runNoThrow(cwd, cmd) {
try {
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })(cmd);
} catch (e) {
return e;
}
}

async function install(packageManager, cwd) {
// All package managers have an install command
await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`${packageManager} install`;
}

async function typecheck(packageManager, cwd) {
banner('typecheck');
switch (packageManager) {
case 'npm':
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`npm exec glint`;
return runNoThrow(cwd, `npm exec glint`);
case 'yarn':
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`yarn glint`;
return runNoThrow(cwd, `yarn glint`);
case 'pnpm':
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`pnpm glint`;
return runNoThrow(cwd, `pnpm glint`);
}
}
async function build(packageManager, cwd) {
banner('build');
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`${packageManager} run build`;
return runNoThrow(cwd, `${packageManager} run build`);
}

async function test(packageManager, cwd) {
banner('test');
return await $({ preferLocal: true, shell: true, cwd, stdio: 'inherit' })`${packageManager} run test:vite`;
return runNoThrow(cwd, `${packageManager} run test:vite`);
}

function banner(text) {
Expand Down Expand Up @@ -179,9 +184,13 @@ async function main() {
await copyTars(projectDir);
await fixManifest(projectDir);
await fixTSConfig(projectDir);

banner('typecheck');
await install(packageManager, projectDir);
let typesResult = await typecheck(packageManager, projectDir);
banner('build');
let buildResult = await build(packageManager, projectDir);
banner('test');
let testResult = await test(packageManager, projectDir);

console.info(`
Expand All @@ -192,6 +201,8 @@ async function main() {
build: ${buildResult.exitCode === 0 ? 'Success' : 'Failure'}
test: ${testResult.exitCode === 0 ? 'Success' : 'Failure'}
`);

process.exit(typesResult.exitCode || buildResult.exitCode || testResult.exitCode);
}

await main();

0 comments on commit 4593741

Please sign in to comment.