forked from devcontainers/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathworkspaces.ts
More file actions
35 lines (31 loc) · 1.33 KB
/
Copy pathworkspaces.ts
File metadata and controls
35 lines (31 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
export interface Workspace {
readonly isWorkspaceFile: boolean;
readonly workspaceOrFolderPath: string;
readonly rootFolderPath: string;
readonly configFolderPath: string;
}
export function workspaceFromPath(path_: typeof path.posix | typeof path.win32, workspaceOrFolderPath: string): Workspace {
if (isWorkspacePath(workspaceOrFolderPath)) {
const workspaceFolder = path_.dirname(workspaceOrFolderPath);
return {
isWorkspaceFile: true,
workspaceOrFolderPath,
rootFolderPath: workspaceFolder, // use workspaceFolder as root folder
configFolderPath: workspaceFolder, // have config file in workspaceFolder (to be discussed...)
};
}
return {
isWorkspaceFile: false,
workspaceOrFolderPath,
rootFolderPath: workspaceOrFolderPath,
configFolderPath: workspaceOrFolderPath,
};
}
export function isWorkspacePath(workspaceOrFolderPath: string) {
return path.extname(workspaceOrFolderPath) === '.code-workspace'; // TODO: Remove VS Code specific code.
}