Skip to content

Commit

Permalink
test: support test.utils.command-exists on Windows
Browse files Browse the repository at this point in the history
`cat` is a common utility on Unix systems, however, it is not
universally available.  On Windows systems, resort to `cmd` (%COMSPEC%)
as the shell interpreter is guaranteed to be present.  It stands to
reason that `sh` would be a viable alternative to `cat` as that is the
default (POSIX) shell interpreter on Unix systems and should be present
on any SuS or POSIX complaint system.
  • Loading branch information
compnerd committed May 9, 2021
1 parent e4dadc1 commit 89eba84
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion test/utils/command-exists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ const commandExists = require("../../src/utils/command-exists");

describe("commandExists()", () => {
test("should return `true` for existing command", async () => {
await expect(commandExists("cat")).resolves.toEqual(true);
if (process.platform === "win32") {
await expect(commandExists("cmd")).resolves.toEqual(true);
} else {
await expect(commandExists("cat")).resolves.toEqual(true);
}
});

test("should return `false` for non-existent command", async () => {
Expand Down

0 comments on commit 89eba84

Please sign in to comment.