Support "~" in getAbsoluteAndInOsFormat
This commit is contained in:
parent
49eae307cd
commit
d85ab889b3
@ -1,4 +1,5 @@
|
||||
import { isAbsolute as pathIsAbsolute, sep as pathSep, join as pathJoin } from "path";
|
||||
import { isAbsolute as pathIsAbsolute, sep as pathSep, join as pathJoin, resolve as pathResolve } from "path";
|
||||
import * as os from "os";
|
||||
|
||||
export function getAbsoluteAndInOsFormatPath(params: { pathIsh: string; cwd: string }): string {
|
||||
const { pathIsh, cwd } = params;
|
||||
@ -7,11 +8,17 @@ export function getAbsoluteAndInOsFormatPath(params: { pathIsh: string; cwd: str
|
||||
|
||||
pathOut = pathOut.replace(/\//g, pathSep);
|
||||
|
||||
if (pathOut.startsWith("~")) {
|
||||
pathOut = pathOut.replace("~", os.homedir());
|
||||
}
|
||||
|
||||
pathOut = pathOut.endsWith(pathSep) ? pathOut.slice(0, -1) : pathOut;
|
||||
|
||||
if (!pathIsAbsolute(pathOut)) {
|
||||
pathOut = pathJoin(cwd, pathOut);
|
||||
}
|
||||
|
||||
pathOut = pathResolve(pathOut);
|
||||
|
||||
return pathOut;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user