-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathupdate.ts
52 lines (48 loc) · 1.77 KB
/
update.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
//===----------------------------------------------------------------------===//
//
// 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 { FolderContext } from "../../FolderContext";
import { WorkspaceContext } from "../../WorkspaceContext";
import { createSwiftTask, SwiftTaskProvider } from "../../tasks/SwiftTaskProvider";
import { executeTaskWithUI, updateAfterError } from "./../utilities";
/**
* Executes a {@link vscode.Task task} to update this package's dependencies.
*/
export async function updateDependencies(ctx: WorkspaceContext) {
const current = ctx.currentFolder;
if (!current) {
return;
}
await updateFolderDependencies(current);
}
/**
* Run `swift package update` inside a folder
* @param folderContext folder to run update inside
*/
export async function updateFolderDependencies(folderContext: FolderContext) {
const task = createSwiftTask(
["package", "update"],
SwiftTaskProvider.updatePackageName,
{
cwd: folderContext.folder,
scope: folderContext.workspaceFolder,
prefix: folderContext.name,
presentationOptions: { reveal: vscode.TaskRevealKind.Silent },
},
folderContext.workspaceContext.toolchain
);
await executeTaskWithUI(task, "Updating Dependencies", folderContext).then(result => {
updateAfterError(result, folderContext);
});
}