MCPcopy Create free account
hub / github.com/Dart-Code/Dart-Code / runPackageCommand

Method runPackageCommand

src/extension/commands/packages.ts:135–177  ·  view source on GitHub ↗
(
		uri: string | vs.Uri | vs.Uri[] | undefined,
		operationProgress: OperationProgress | undefined,
		options: {
			placeHolder: string,
			progressTitle: string,
			runForUri: (uri: vs.Uri, operationProgress?: OperationProgress) => Promise<RunProcessResult | undefined>,
		},
		{ onlyShowWorkspaceRoots = false }: { onlyShowWorkspaceRoots?: boolean; } = {}
	)

Source from the content-addressed store, hash-verified

133 }
134
135 private async runPackageCommand(
136 uri: string | vs.Uri | vs.Uri[] | undefined,
137 operationProgress: OperationProgress | undefined,
138 options: {
139 placeHolder: string,
140 progressTitle: string,
141 runForUri: (uri: vs.Uri, operationProgress?: OperationProgress) => Promise<RunProcessResult | undefined>,
142 },
143 { onlyShowWorkspaceRoots = false }: { onlyShowWorkspaceRoots?: boolean; } = {}
144 ): Promise<RunProcessResult | undefined> {
145 if (!config.enablePub)
146 return;
147
148 if (!operationProgress) {
149 return vs.window.withProgress({
150 cancellable: true,
151 location: vs.ProgressLocation.Notification,
152 title: options.progressTitle,
153 }, (progress, token) => this.runPackageCommand(uri, { progressReporter: progress, cancellationToken: token }, options, { onlyShowWorkspaceRoots }));
154 }
155
156 if (Array.isArray(uri)) {
157 uri = getPubWorkspaceOrPackageFolderUris(uri);
158 if (uri.length === 1)
159 uri = uri[0];
160 } else if (typeof uri === "string") {
161 uri = getPubWorkspaceFolderOrPackageFolderPath(uri);
162 } else if (uri) {
163 uri = getPubWorkspaceFolderOrPackageFolderUri(uri);
164 }
165
166 if (Array.isArray(uri)) {
167 const uris = uri.map((item) => typeof item === "string" ? vs.Uri.file(item) : item);
168 await runBatchFolderOperation(uris, operationProgress, options.runForUri);
169 return;
170 }
171
172 const resolvedUri = await this.resolvePackageTargetUri(uri, options.placeHolder, { onlyShowWorkspaceRoots });
173 if (!resolvedUri)
174 return;
175
176 return options.runForUri(resolvedUri, operationProgress);
177 }
178
179 private async runPackageCommandForUri(uri: vs.Uri, args: string[], operationProgress?: OperationProgress): Promise<RunProcessResult | undefined> {
180 // Exclude folders we should never run pub commands for.

Callers 2

getPackagesMethod · 0.95
upgradePackagesMethod · 0.95

Tested by

no test coverage detected