diff --git a/src/finder.coffee b/src/finder.coffee index 57e9d66..e8448c9 100644 --- a/src/finder.coffee +++ b/src/finder.coffee @@ -10,11 +10,11 @@ export class Finder {extensions = [], paths = []} = options unless extensions.length - pathExt = process.env.PATHEXT ? "" + pathExt = process.env.PATHEXT or "" extensions = if pathExt then pathExt.split ";" else [".exe", ".cmd", ".bat", ".com"] unless paths.length - pathEnv = process.env.PATH ? "" + pathEnv = process.env.PATH or "" paths = if pathEnv then pathEnv.split(if Finder.isWindows then ";" else delimiter) else [] # The list of executable file extensions. diff --git a/test/finder_test.coffee b/test/finder_test.coffee index 6057cfe..8b216a6 100644 --- a/test/finder_test.coffee +++ b/test/finder_test.coffee @@ -8,12 +8,12 @@ import {describe, it} from "node:test" describe "Finder", -> describe "constructor()", -> it "should set the `paths` property to the value of the `PATH` environment variable by default", -> - pathEnv = env.PATH ? "" + pathEnv = env.PATH or "" paths = new Set if pathEnv then pathEnv.split(if Finder.isWindows then ";" else delimiter).filter (item) -> item.length else [] equal new Finder().paths.symmetricDifference(paths).size, 0 it "should set the `extensions` property to the value of the `PATHEXT` environment variable by default", -> - pathExt = env.PATHEXT ? "" + pathExt = env.PATHEXT or "" extensions = new Set if pathExt then pathExt.split(";").map (item) -> item.toLowerCase() else [".exe", ".cmd", ".bat", ".com"] equal new Finder().extensions.symmetricDifference(extensions).size, 0