Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.11.0

- Breaking Change: Replace export `childProcess.exec()` with `childProcess.execFile()`

## 0.10.5

- Bump `glob` from `^12.0.0` to `^13.0.0`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@azure/avocado",
"version": "0.10.5",
"version": "0.11.0",
"description": "A validator of OpenAPI configurations",
"type": "module",
"main": "dist/index.js",
Expand Down
9 changes: 6 additions & 3 deletions src/child-process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import * as childProcess from 'child_process'
import * as util from 'util'

const nodeJsExec = util.promisify(childProcess.exec)
const nodeJsExecFile = util.promisify(childProcess.execFile)

export type ExecResult = {
/**
Expand All @@ -17,5 +17,8 @@ export type ExecResult = {
readonly stderr: string
}

export const exec = (command: string, options: childProcess.ExecOptionsWithStringEncoding): Promise<ExecResult> =>
nodeJsExec(command, { maxBuffer: Infinity, ...options })
export const execFile = (
file: string,
args: readonly string[],
options: childProcess.ExecFileOptionsWithStringEncoding,
): Promise<ExecResult> => nodeJsExecFile(file, args, { maxBuffer: Infinity, ...options })
2 changes: 1 addition & 1 deletion src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export const repository =
GIT_TERMINAL_PROMPT: '0',
},
}
return childProcess.exec(`git ${cmd} ${args.join(' ')}`, options)
return childProcess.execFile('git', [cmd, ...args], options)
}
7 changes: 4 additions & 3 deletions src/test/child-process-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ import { childProcess } from '../index.js'
import { generate } from './generate-stdout.js'

describe('child-process', () => {
it('exec maxBuffer', async () => {
it('execFile maxBuffer', async () => {
// call `generate-stdout.print()` as a separate process.
const { stdout } = await childProcess.exec(
'node -e "import { print } from \'./dist/test/generate-stdout.js\'; print();"',
const { stdout } = await childProcess.execFile(
'node',
['-e', "import { print } from './dist/test/generate-stdout.js'; print();"],
{},
)
const expected = generate()
Expand Down
Loading