Skip to content

Commit

Permalink
fix: --exec ENOENT tinyexec args, close antfu-collective#62
Browse files Browse the repository at this point in the history
  • Loading branch information
YunYouJun committed Dec 11, 2024
1 parent 1229cd7 commit 4053863
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/version-bump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,11 @@ export async function versionBump(arg: (VersionBumpOptions) | string = {}): Prom
}
else {
console.log(symbols.info, 'Executing script', operation.options.execute)
await x(operation.options.execute, [], {
const [command, ...args] = operation.options.execute.split(' ')
await x(command, args, {
nodeOptions: {
stdio: 'inherit',
cwd: operation.options.cwd,
},
})
console.log(symbols.success, 'Script finished')
Expand Down
23 changes: 23 additions & 0 deletions test/exec.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { existsSync } from 'node:fs'
import { mkdir } from 'node:fs/promises'
import { join } from 'node:path'
import { cwd } from 'node:process'
import { expect, it } from 'vitest'
import { versionBump } from '../src'

const distDir = join(cwd(), 'test', 'fixture', 'dist')

it('exec command to clean dist dir', async () => {
if (!existsSync(distDir)) {
await mkdir(distDir)
}

expect(existsSync(distDir)).toBeTruthy()
await versionBump({
cwd: join(cwd(), 'test', 'fixture'),
release: '0.0.1',
confirm: false,
execute: 'npm run clean',
})
expect(existsSync(distDir)).toBeFalsy()
})
6 changes: 6 additions & 0 deletions test/fixture/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "0.0.1",
"scripts": {
"clean": "rimraf dist"
}
}

0 comments on commit 4053863

Please sign in to comment.