-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathedit.ts
58 lines (53 loc) · 1.83 KB
/
edit.ts
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//===----------------------------------------------------------------------===//
//
// This source file is part of the VS Code Swift open source project
//
// Copyright (c) 2024 Apple Inc. and the VS Code Swift project authors
// Licensed under Apache License v2.0
//
// See LICENSE.txt for license information
// See CONTRIBUTORS.txt for the list of VS Code Swift project authors
//
// SPDX-License-Identifier: Apache-2.0
//
//===----------------------------------------------------------------------===//
import * as vscode from "vscode";
import { createSwiftTask } from "../../tasks/SwiftTaskProvider";
import { FolderOperation, WorkspaceContext } from "../../WorkspaceContext";
import { executeTaskWithUI } from "../utilities";
/**
* Setup package dependency to be edited
* @param identifier Identifier of dependency we want to edit
* @param ctx workspace context
*/
export async function editDependency(identifier: string, ctx: WorkspaceContext) {
const currentFolder = ctx.currentFolder;
if (!currentFolder) {
return;
}
const task = createSwiftTask(
["package", "edit", identifier],
"Edit Package Dependency",
{
scope: currentFolder.workspaceFolder,
cwd: currentFolder.folder,
prefix: currentFolder.name,
},
ctx.toolchain
);
const success = await executeTaskWithUI(
task,
`edit locally ${identifier}`,
currentFolder,
true
);
if (success) {
ctx.fireEvent(currentFolder, FolderOperation.resolvedUpdated);
// add folder to workspace
const index = vscode.workspace.workspaceFolders?.length ?? 0;
vscode.workspace.updateWorkspaceFolders(index, 0, {
uri: vscode.Uri.file(currentFolder.editedPackageFolder(identifier)),
name: identifier,
});
}
}