Skip to content

Commit

Permalink
Don't do PATH check in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
ericcornelissen committed Oct 11, 2023
1 parent abaae3d commit de29baa
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions script/maybe-run.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
/**
* @overview Run a tool if it's present on the PATH, otherwise output a warning.
* If used in a CI context, the tool will be run without any checks.
* @license MIT-0
*/

import process from "node:process";

import isCI from "is-ci";
import which from "which";

import { common } from "./_.js";
Expand All @@ -17,14 +19,16 @@ if (common.argv.length === 0) {
const cmd = common.argv[0];
const args = common.argv.slice(1);

try {
which.sync(cmd);
} catch (_) {
console.warn(
`Command '${cmd}' not found, it will not be run.`,
"Install it to make this warning go away.",
);
process.exit(0);
if (!isCI) {
try {
which.sync(cmd);
} catch (_) {
console.warn(
`Command '${cmd}' not found, it will not be run.`,
"Install it to make this warning go away.",
);
process.exit(0);
}
}

const { status } = common.spawnSync(cmd, args);
Expand Down

0 comments on commit de29baa

Please sign in to comment.