From a8477cb2341ca92fa05019b7438aac3ce3e111fe Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Fri, 17 Sep 2021 04:49:13 -0500 Subject: [PATCH] test: escape path in the exec in the test --- package.json | 3 ++- pnpm-lock.yaml | 6 ++++++ src/utils/tests/test-helpers.ts | 5 ++++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 5b5e1c3d..032f90c1 100644 --- a/package.json +++ b/package.json @@ -61,7 +61,8 @@ "shx": "0.3.3", "terser-config-atomic": "^0.1.1", "ts-jest": "^27.0.5", - "typescript": "^4.4.3" + "typescript": "^4.4.3", + "escape-path-with-spaces": "^1.0.0" }, "keywords": [ "github-actions", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 142db67c..bb1d5f8c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -17,6 +17,7 @@ importers: '@types/which': ^2.0.1 caxa: ^2.1.0 cross-env: 7.0.3 + escape-path-with-spaces: ^1.0.0 eslint-config-atomic: ^1.16.2 hasha: ^5.2.2 jest: ^27.2.0 @@ -44,6 +45,7 @@ importers: '@types/which': 2.0.1 caxa: 2.1.0 cross-env: 7.0.3 + escape-path-with-spaces: 1.0.0 eslint-config-atomic: 1.16.2 jest: 27.2.0 npm-run-all2: 5.0.2 @@ -3373,6 +3375,10 @@ packages: resolution: {integrity: sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=} dev: true + /escape-path-with-spaces/1.0.0: + resolution: {integrity: sha512-+98Hh0yzVa0hldJXlzr0M/8B8LVXW9vNT5boC9k6o896Z52DGRplm3NwMGX0590ryGSegzTf/uaUiusFj2SQbQ==} + dev: true + /escape-string-regexp/1.0.5: resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=} engines: {node: '>=0.8.0'} diff --git a/src/utils/tests/test-helpers.ts b/src/utils/tests/test-helpers.ts index 8ceded1c..02548c89 100644 --- a/src/utils/tests/test-helpers.ts +++ b/src/utils/tests/test-helpers.ts @@ -4,6 +4,9 @@ import * as path from "path" import { addBinExtension } from "../setup/setupBin" import { join } from "path" import { exec } from "@actions/exec" +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-ignore +import escape from "escape-path-with-spaces" export async function setupTmpDir(testName: string) { const tempDirectory = path.join(tmpdir(), "setup-cpp", testName) @@ -41,7 +44,7 @@ export async function testBin(name: string, args: string[] = ["--version"], binD bin = join(binDir, addBinExtension(name)) } - const status = await exec(bin, args) + const status = await exec(escape(bin) as string, args) expect(status).toBe(0) expect(await io.which(name, true)).toBe(bin)