diff --git a/__tests__/gobin.test.ts b/__tests__/gobin.test.ts index a34fc21..dc2ee48 100644 --- a/__tests__/gobin.test.ts +++ b/__tests__/gobin.test.ts @@ -6,12 +6,12 @@ jest.mock('child_process'); describe('gobin', () => { const childProcess = require('child_process'); - let execSpy: jest.SpyInstance; + let execFileSpy: jest.SpyInstance; let gopath = path.join('home', 'user', 'go'); beforeEach(() => { - execSpy = jest.spyOn(childProcess, 'exec'); - execSpy.mockImplementation((_command, callback) => { + execFileSpy = jest.spyOn(childProcess, 'execFile'); + execFileSpy.mockImplementation((_file, _args, callback) => { callback('', {stdout: gopath, stderr: ''}); }); }); diff --git a/dist/index.js b/dist/index.js index 1a9859a..fe283d6 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3275,11 +3275,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); const childProcess = __importStar(__webpack_require__(129)); const path = __importStar(__webpack_require__(622)); const util_1 = __webpack_require__(669); -const exec = util_1.promisify(childProcess.exec); +const execFile = util_1.promisify(childProcess.execFile); function getGOBIN(installDir) { return __awaiter(this, void 0, void 0, function* () { const goExecutable = path.join(installDir, 'bin', 'go'); - const result = yield exec(`${goExecutable} env GOPATH`); + const result = yield execFile(goExecutable, ['env', 'GOPATH']); const gopath = result.stdout; return path.join(gopath, 'bin'); }); diff --git a/src/gobin.ts b/src/gobin.ts index d711cfd..199c878 100644 --- a/src/gobin.ts +++ b/src/gobin.ts @@ -2,12 +2,12 @@ import * as childProcess from 'child_process'; import * as path from 'path'; import {promisify} from 'util'; -const exec = promisify(childProcess.exec); +const execFile = promisify(childProcess.execFile); export async function getGOBIN(installDir: string): Promise { const goExecutable = path.join(installDir, 'bin', 'go'); - const result = await exec(`${goExecutable} env GOPATH`); + const result = await execFile(goExecutable, ['env', 'GOPATH']); const gopath = result.stdout; return path.join(gopath, 'bin'); }