Skip to content

Commit

Permalink
Code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
cedx committed Nov 12, 2024
1 parent 76c1e87 commit 66c8668
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/finder.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions test/finder_test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 66c8668

Please sign in to comment.