MCPcopy
hub / github.com/Kong/insomnia / getAbsoluteFilePath

Function getAbsoluteFilePath

packages/insomnia-inso/src/cli.ts:105–118  ·  view source on GitHub ↗
({ workingDir, file }: { workingDir?: string; file: string })

Source from the content-addressed store, hash-verified

103const localAppDir = getAppDataDir(getDefaultProductName());
104
105export const getAbsoluteFilePath = ({ workingDir, file }: { workingDir?: string; file: string }) => {
106 if (!file) {
107 return '';
108 }
109
110 if (workingDir) {
111 if (fs.existsSync(workingDir) && !fs.statSync(workingDir).isDirectory()) {
112 return nodePath.resolve(nodePath.dirname(workingDir), file);
113 }
114 return nodePath.resolve(workingDir, file);
115 }
116
117 return nodePath.resolve(process.cwd(), file);
118};
119export const logErrorAndExit = (err?: Error) => {
120 if (err instanceof InsoError) {
121 logger.fatal(err.message);

Callers 1

goFunction · 0.85

Calls 2

isDirectoryMethod · 0.80
resolveMethod · 0.45

Tested by

no test coverage detected