Skip to content

Commit

Permalink
refactor ~ convert anonymous to named functions/methods
Browse files Browse the repository at this point in the history
  • Loading branch information
rivy committed Jan 30, 2021
1 parent 4106f0b commit d0d78c8
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/lib/OSPaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ function isEmpty(s: string | null | undefined): boolean {

// eslint-disable-next-line @typescript-eslint/no-namespace
namespace Adapt {
export const isWinOS = (adapter_: Platform.Adapter) => /^win/i.test(adapter_.process.platform);
export function isWinOS(adapter_: Platform.Adapter) {
return /^win/i.test(adapter_.process.platform);
}

export const normalizePath = (adapter_: Platform.Adapter) => {
export function normalizePath(adapter_: Platform.Adapter) {
return (path_: string | undefined): string | undefined => {
return path_ ? adapter_.path.normalize(adapter_.path.join(path_, '.')) : void 0;
};
};
}

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

const normalizePath = Adapt.normalizePath(adapter_);
Expand All @@ -51,9 +53,9 @@ namespace Adapt {
};

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

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

const normalizePath = Adapt.normalizePath(adapter_);
Expand Down Expand Up @@ -91,7 +93,7 @@ namespace Adapt {
};

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

export function OSPathsAdaptionBuilder_(adapter_: Platform.Adapter): OSPaths {
Expand All @@ -101,10 +103,6 @@ export function OSPathsAdaptionBuilder_(adapter_: Platform.Adapter): OSPaths {
const home = Adapt.home(adapter_);
const temp = Adapt.temp(adapter_);

// retouch method names
Object.defineProperty(home, 'name', { value: 'home' });
Object.defineProperty(temp, 'name', { value: 'temp' });

const obj = Object.assign(OSPaths, {
home,
temp,
Expand Down

0 comments on commit d0d78c8

Please sign in to comment.