(p: T)
| 45 | && (!dartExtension || dartExtension.extensionKind === ExtensionKind.UI); |
| 46 | |
| 47 | export function resolvePaths<T extends string | undefined>(p: T): string | (undefined extends T ? undefined : never) { |
| 48 | if (typeof p !== "string") |
| 49 | return undefined as (undefined extends T ? undefined : never); |
| 50 | |
| 51 | if (p.startsWith("~/")) |
| 52 | return path.join(os.homedir(), p.substr(2)); |
| 53 | if (!path.isAbsolute(p)) { |
| 54 | const relativePathBase = workspace.workspaceFile?.scheme === "file" |
| 55 | ? path.dirname(fsPath(workspace.workspaceFile)) |
| 56 | : workspace.workspaceFolders?.length |
| 57 | ? fsPath(workspace.workspaceFolders[0].uri) |
| 58 | : undefined; |
| 59 | if (relativePathBase) |
| 60 | return path.join(relativePathBase, p); |
| 61 | } |
| 62 | return p; |
| 63 | } |
| 64 | |
| 65 | export function getDartWorkspaceFolders(): WorkspaceFolder[] { |
| 66 | if (!workspace.workspaceFolders) |
no test coverage detected