Skip to content

chore: use tinyexec - #1213

Open
sacrosanctic wants to merge 14 commits into
sveltejs:mainfrom
sacrosanctic:tinyexec
Open

chore: use tinyexec#1213
sacrosanctic wants to merge 14 commits into
sveltejs:mainfrom
sacrosanctic:tinyexec

Conversation

@sacrosanctic

Copy link
Copy Markdown
Contributor

Closes #

Description

Checklist

  • Update snapshots (if applicable)
  • Add a changeset (if applicable)
  • Allow maintainers to edit this PR
  • I care about what I'm doing, no matter the tool I use (Notepad, Sublime, VSCode, AI...)

@pkg-svelte-dev

pkg-svelte-dev Bot commented Aug 1, 2026

Copy link
Copy Markdown

Install the latest version of sv from ea6eb58:

pnpm add https://pkg.svelte.dev/sv/c/ea6eb5884f9b5ad9f04513d02d7ff871c978a8c0

Open in pkg.svelte.dev: https://pkg.svelte.dev/repos/cli/pr/1213

Note

This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed.

@changeset-bot

changeset-bot Bot commented Aug 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ea6eb58

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@sacrosanctic sacrosanctic left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if these are supposed to throw.

if (process.platform === 'win32') {
// on windows, use taskkill to terminate the process tree
await exec('taskkill', ['/PID', `${pid}`, '/T', '/F']);
await exec('taskkill', ['/PID', `${pid}`, '/T', '/F'], { throwOnError: true });

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this

@AdrianGonz97 AdrianGonz97 Aug 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd wager to say no, it shouldn't throw given that it didn't throw before. im also guessing it exits with a non-zero exit code if the process no longer exists, which we wouldnt want to throw on anyway

Comment on lines 128 to +368
@@ -363,7 +363,10 @@ export function createSetupTest(
}

const installDir = path.resolve(cwd, testName);
const install = await exec('pnpm', ['install'], { nodeOptions: { cwd: installDir } });
const install = await exec('pnpm', ['install'], {
nodeOptions: { cwd: installDir },
throwOnError: true

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not throw since it's being handled in the lines directly underneath it

Comment on lines 1 to +3
import fs from 'node:fs';
import path from 'node:path';
import { execSync } from 'tinyexec';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same

Comment thread packages/sv/src/core/verifiers.ts Outdated
Comment on lines +43 to 44
if (reasons.length === 0) return { success: true, message: undefined };
throw new UnsupportedError(reasons);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my old eyes aren't what they used to be - it's easier to read with the spacing :p

Suggested change
if (reasons.length === 0) return { success: true, message: undefined };
throw new UnsupportedError(reasons);
if (reasons.length === 0) {
return { success: true, message: undefined };
}
throw new UnsupportedError(reasons);

await exec(command, args, { nodeOptions: { cwd }, throwOnError: true });
return {};
} catch (e) {
// @ts-expect-error tinyexec rethrows the spawn error as-is

@AdrianGonz97 AdrianGonz97 Aug 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// @ts-expect-error tinyexec rethrows the spawn error as-is

I know you didn't change this catch-block, but is this still correct? Looking through NonZeroExitError, I don't see e.code as an available prop.


try {
execSync('docker --version', { cwd, stdio: 'pipe' });
execSync('docker', ['--version'], { nodeOptions: { cwd } });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should throw

Suggested change
execSync('docker', ['--version'], { nodeOptions: { cwd } });
execSync('docker', ['--version'], { nodeOptions: { cwd }, throwOnError: true });

if (process.platform === 'win32') {
// on windows, use taskkill to terminate the process tree
await exec('taskkill', ['/PID', `${pid}`, '/T', '/F']);
await exec('taskkill', ['/PID', `${pid}`, '/T', '/F'], { throwOnError: true });

@AdrianGonz97 AdrianGonz97 Aug 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd wager to say no, it shouldn't throw given that it didn't throw before. im also guessing it exits with a non-zero exit code if the process no longer exists, which we wouldnt want to throw on anyway

fs.writeFileSync(pageServerPath, pageServer, 'utf8');

execSync('npm run db:push', { cwd, stdio: 'pipe' });
execSync('npm', ['run', 'db:push'], { nodeOptions: { cwd } });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

execSync from node:child_process throws by default on non-zero exit codes. it should probably throw here as well

Suggested change
execSync('npm', ['run', 'db:push'], { nodeOptions: { cwd } });
execSync('npm', ['run', 'db:push'], { nodeOptions: { cwd } });


// Generate auth schema using better-auth CLI
execSync('npm run auth:schema', { cwd, stdio: 'pipe' });
execSync('npm', ['run', 'auth:schema'], { nodeOptions: { cwd } });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same for this


// Push schema to DB
execSync('npm run db:push -- --force', { cwd, stdio: 'pipe' });
execSync('npm', ['run', 'db:push', '--', '--force'], { nodeOptions: { cwd } });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and this

}

if (dockerInstalled) execSync('docker compose up --detach', { cwd, stdio: 'pipe' });
if (dockerInstalled) execSync('docker', ['compose', 'up', '--detach'], { nodeOptions: { cwd } });

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one should probably throw (or at least be handled in some way) as well if we're depending on it running successfully


fs.writeFileSync(path.join(test_workspace_dir, 'pnpm-workspace.yaml'), 'packages:\n - ./*\n');

const exec_async = promisify(nodeExec);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, there was a reason we used this instead due to failing tests, but if it's no longer failing then we're probably good

Co-authored-by: CokaKoala <31664583+AdrianGonz97@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants