forked from swiftlang/vscode-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.ts
54 lines (50 loc) · 1.89 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
53
54
//===----------------------------------------------------------------------===//
//
// This source file is part of the VS Code Swift open source project
//
// Copyright (c) 2021-2024 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";
import configuration from "../../configuration";
/**
* Executes a {@link vscode.Task task} to update this package's dependencies.
*/
export async function updateDependencies(ctx: WorkspaceContext) {
const current = ctx.currentFolder;
if (!current) {
ctx.outputChannel.log("currentFolder is not set.");
return false;
}
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
);
const result = await executeTaskWithUI(task, "Updating Dependencies", folderContext);
updateAfterError(result, folderContext);
return result;
}