Skip to content

Commit

Permalink
refactor ~ reduce const isWinOS to a function call (improves DRY, r…
Browse files Browse the repository at this point in the history
…educes duplication)
  • Loading branch information
rivy committed Jan 30, 2021
1 parent eafe6cb commit 4106f0b
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/lib/OSPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ namespace Adapt {
export const home = (adapter_: Platform.Adapter) => {
const { env, os, path } = adapter_;

const isWinOS = Adapt.isWinOS(adapter_);
const normalizePath = Adapt.normalizePath(adapter_);

const posix = () =>
Expand All @@ -51,13 +50,12 @@ namespace Adapt {
return normalizePath(priorityList.find((v) => !isEmpty(v)));
};

return isWinOS ? windows : posix;
return Adapt.isWinOS(adapter_) ? windows : posix;
};

export const temp = (adapter_: Platform.Adapter) => {
const { env, os, path } = adapter_;

const isWinOS = Adapt.isWinOS(adapter_);
const normalizePath = Adapt.normalizePath(adapter_);

function joinPathToBase(base: string | undefined, segments: readonly string[]) {
Expand Down Expand Up @@ -92,7 +90,7 @@ namespace Adapt {
return (v && normalizePath(v())) || fallback;
};

return isWinOS ? windows : posix;
return Adapt.isWinOS(adapter_) ? windows : posix;
};
}

Expand Down

0 comments on commit 4106f0b

Please sign in to comment.