diff --git a/CHANGELOG.md b/CHANGELOG.md index 799aebf..701afa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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` diff --git a/package.json b/package.json index 3daa3b2..3b515c1 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/child-process.ts b/src/child-process.ts index c250056..6915537 100644 --- a/src/child-process.ts +++ b/src/child-process.ts @@ -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 = { /** @@ -17,5 +17,8 @@ export type ExecResult = { readonly stderr: string } -export const exec = (command: string, options: childProcess.ExecOptionsWithStringEncoding): Promise => - nodeJsExec(command, { maxBuffer: Infinity, ...options }) +export const execFile = ( + file: string, + args: readonly string[], + options: childProcess.ExecFileOptionsWithStringEncoding, +): Promise => nodeJsExecFile(file, args, { maxBuffer: Infinity, ...options }) diff --git a/src/git.ts b/src/git.ts index 72fc5b2..4d4e418 100644 --- a/src/git.ts +++ b/src/git.ts @@ -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) } diff --git a/src/test/child-process-test.ts b/src/test/child-process-test.ts index c5e5abe..0f6a64f 100644 --- a/src/test/child-process-test.ts +++ b/src/test/child-process-test.ts @@ -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()