Skip to content

Commit 52d8312

Browse files
authored
refactor: replace simple-git with tinyexec (#950)
1 parent 56b8c97 commit 52d8312

4 files changed

Lines changed: 11 additions & 40 deletions

File tree

packages/devtools/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
"perfect-debounce": "catalog:frontend",
7676
"pkg-types": "catalog:prod",
7777
"semver": "catalog:prod",
78-
"simple-git": "catalog:prod",
7978
"sirv": "catalog:prod",
8079
"structured-clone-es": "catalog:frontend",
8180
"tinyexec": "catalog:prod",

packages/devtools/src/server-rpc/analyze-build.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import fs from 'node:fs'
44
import fsp from 'node:fs/promises'
55
import { startSubprocess } from '@nuxt/devtools-kit'
66
import { dirname, join } from 'pathe'
7-
import Git from 'simple-git'
7+
import { x } from 'tinyexec'
88
import { glob } from 'tinyglobby'
99

1010
const COLON_RE = /:/g
@@ -87,14 +87,18 @@ export function setupAnalyzeBuildRPC({ nuxt, refresh, ensureDevAuthToken }: Nuxt
8787
return builds.sort((a, b) => b.endTime - a.endTime)
8888
}
8989

90+
async function git(...args: string[]): Promise<string> {
91+
const result = await x('git', args, { nodeOptions: { cwd: nuxt.options.rootDir }, throwOnError: true })
92+
return result.stdout.trim()
93+
}
94+
9095
async function generateAnalyzeBuildName() {
9196
try {
92-
const git = Git(nuxt.options.rootDir)
93-
const branch = await git.branch()
94-
const branchName = branch.current || 'head'
95-
const sha = await git.revparse(['--short', 'HEAD'])
96-
const isWorkingTreeClean = (await git.status()).isClean()
97-
if (isWorkingTreeClean)
97+
const branchName = await git('rev-parse', '--abbrev-ref', 'HEAD') || 'head'
98+
const sha = await git('rev-parse', '--short', 'HEAD')
99+
const status = await git('status', '--porcelain')
100+
const isClean = status === ''
101+
if (isClean)
98102
return `${branchName}#${sha}`
99103
return `${branchName}#${sha}-dirty`
100104
}

pnpm-lock.yaml

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

pnpm-workspace.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ catalogs:
127127
nypm: ^0.6.5
128128
pkg-types: ^2.3.0
129129
semver: ^7.7.4
130-
simple-git: ^3.33.0
131130
sirv: ^3.0.2
132131
tinyexec: ^1.0.4
133132
tinyglobby: ^0.2.15

0 commit comments

Comments
 (0)