Skip to content

Commit d0f0638

Browse files
authored
refactor: replace execa with tinyexec (#79)
1 parent 6f3225a commit d0f0638

File tree

5 files changed

+33
-144
lines changed

5 files changed

+33
-144
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@
2929
"dependencies": {
3030
"conventional-changelog": "^7.1.1",
3131
"conventional-changelog-conventionalcommits": "^9.1.0",
32-
"execa": "^8.0.1",
3332
"mri": "^1.2.0",
3433
"picocolors": "^1.1.1",
3534
"prompts": "^2.4.2",
3635
"publint": "^0.3.12",
37-
"semver": "^7.7.2"
36+
"semver": "^7.7.2",
37+
"tinyexec": "^0.3.2"
3838
},
3939
"devDependencies": {
4040
"@arnaud-barre/tnode": "^0.25.0",

pnpm-lock.yaml

Lines changed: 3 additions & 126 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/release.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ export const release: typeof def = async ({
101101
updateVersion(pkgPath, targetVersion);
102102
await generateChangelog(selectedPkg, targetVersion);
103103

104-
const { stdout } = await run("git", ["diff"], { stdio: "pipe" });
104+
const { stdout } = await run("git", ["diff"], {
105+
nodeOptions: { stdio: "pipe" },
106+
});
105107
if (stdout) {
106108
step("\nCommitting changes...");
107109
await runIfNotDry("git", ["add", "-A"]);

src/utils.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { writeFileSync, readFileSync } from "node:fs";
22
import path from "node:path";
33
import colors from "picocolors";
4-
import type { Options as ExecaOptions, ExecaReturnValue } from "execa";
5-
import { execa } from "execa";
4+
import type {
5+
Options as TinyExecOptions,
6+
Result as TinyExecResult,
7+
} from "tinyexec";
8+
import { exec } from "tinyexec";
69
import type { ReleaseType } from "semver";
710
import semver from "semver";
811
import mri from "mri";
@@ -38,15 +41,22 @@ export function getPackageInfo(
3841
export async function run(
3942
bin: string,
4043
args: string[],
41-
opts: ExecaOptions = {},
42-
): Promise<ExecaReturnValue> {
43-
return execa(bin, args, { stdio: "inherit", ...opts });
44+
opts: Partial<TinyExecOptions> = {},
45+
): Promise<TinyExecResult> {
46+
return exec(bin, args, {
47+
throwOnError: true,
48+
...opts,
49+
nodeOptions: {
50+
stdio: "inherit",
51+
...opts.nodeOptions,
52+
},
53+
});
4454
}
4555

4656
export async function dryRun(
4757
bin: string,
4858
args: string[],
49-
opts?: ExecaOptions,
59+
opts?: Partial<TinyExecOptions>,
5060
): Promise<void> {
5161
return console.log(
5262
colors.blue(`[dryrun] ${bin} ${args.join(" ")}`),
@@ -151,7 +161,7 @@ export async function publishPackage(
151161
publicArgs.push(`--no-git-checks`);
152162
}
153163
await runIfNotDry(packageManager, publicArgs, {
154-
cwd: pkgDir,
164+
nodeOptions: { cwd: pkgDir },
155165
});
156166
}
157167

@@ -162,7 +172,7 @@ export async function getActiveVersion(
162172
const { stdout } = await run(
163173
"npm",
164174
["info", npmName, "version", "--json"],
165-
{ stdio: "pipe" },
175+
{ nodeOptions: { stdio: "pipe" } },
166176
);
167177
return JSON.parse(stdout);
168178
} catch (e: any) {

0 commit comments

Comments
 (0)