Skip to content

Commit

Permalink
feat: allow to set current working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Apr 3, 2024
1 parent f290e8a commit a91ab70
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/run.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ void describe('run()', () => {
})
assert.equal(log.mock.calls[0]?.arguments[0].toString(), 'test')

Check warning on line 77 in src/run.spec.ts

View workflow job for this annotation

GitHub Actions / tests

Unsafe call of an `any` typed value

Check warning on line 77 in src/run.spec.ts

View workflow job for this annotation

GitHub Actions / tests

Unsafe member access .toString on an `any` value
})

void it('can be launched in a different working directory', async () => {
await run({
command: 'npx',
args: ['tsx', 'stderr.ts'],
cwd: 'src/test',
})
})
})
4 changes: 3 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ const run = async ({
args,
input,
log,
cwd,
}: {
command: string
args?: string[]
input?: string
cwd?: string
log?: {
debug?: (...message: any[]) => void
stdout?: (...message: any[]) => void
Expand All @@ -19,7 +21,7 @@ const run = async ({
}): Promise<string> =>
new Promise((resolve, reject) => {
log?.debug?.(`${command} ${args?.join(' ')}`)
const p = spawn(command, args)
const p = spawn(command, args, { cwd })
const result = [] as string[]
const errors = [] as string[]
if (input !== undefined) {
Expand Down

0 comments on commit a91ab70

Please sign in to comment.