diff --git a/src/extension/commands/packages.ts b/src/extension/commands/packages.ts index f2463fae38..d93f24fa2e 100644 --- a/src/extension/commands/packages.ts +++ b/src/extension/commands/packages.ts @@ -50,28 +50,38 @@ export class PackageCommands extends BaseSdkCommands { } private async getPackages(uri: string | vs.Uri | vs.Uri[] | undefined) { - if (!config.enablePub) + if (!config.enablePub) { + this.logger.warn(`Pub is disabled by config, skipping!`); return; + } if (Array.isArray(uri)) { + this.logger.info(`Fetching packages for array...`); for (const item of uri) { await this.getPackages(item); } return; } + this.logger.info(`Fetching packages for ${uri}!`); + if (!uri || !(uri instanceof vs.Uri)) { + this.logger.info(`No folder, so asking...`); uri = await getFolderToRunCommandIn(this.logger, "Select which folder to get packages for"); // If the user cancelled, bail out (otherwise we'll prompt them again below). - if (!uri) + if (!uri) { + this.logger.warn(`Got no folder, skipping!`); return; + } } if (typeof uri === "string") uri = vs.Uri.file(uri); // Exclude folders we should never run pub get for. - if (!isValidPubGetTarget(uri).valid) + if (!isValidPubGetTarget(uri).valid) { + this.logger.warn(`Folder is not a valid pub get target, so skipping!`); return; + } const additionalArgs = []; if (config.offline) @@ -80,8 +90,10 @@ export class PackageCommands extends BaseSdkCommands { additionalArgs.push("--no-example"); if (util.isInsideFlutterProject(uri)) { + this.logger.info(`Inside a Flutter project, running 'flutter pub get'`); return this.runFlutter(["pub", "get", ...additionalArgs], uri); } else { + this.logger.info(`Inside a Dart project, running 'dart pub get'`); return this.runPub(["get", ...additionalArgs], uri); } } diff --git a/src/extension/commands/sdk.ts b/src/extension/commands/sdk.ts index 7d9a1c2d1e..1a91add802 100644 --- a/src/extension/commands/sdk.ts +++ b/src/extension/commands/sdk.ts @@ -44,8 +44,10 @@ export class BaseSdkCommands implements IAmDisposable { alwaysShowOutput = false, ): Promise { const folderToRunCommandIn = await getFolderToRunCommandIn(this.logger, placeHolder, selection); - if (!folderToRunCommandIn) + if (!folderToRunCommandIn) { + this.logger.error(`No folderToRunCommandIn, skipping!`); return; + } const containingWorkspace = vs.workspace.getWorkspaceFolder(vs.Uri.file(folderToRunCommandIn)); const containingWorkspacePath = containingWorkspace ? fsPath(containingWorkspace.uri) : undefined; @@ -64,8 +66,10 @@ export class BaseSdkCommands implements IAmDisposable { } protected runFlutterInFolder(folder: string, args: string[], shortPath: string | undefined, alwaysShowOutput = false, customScript?: CustomScript): Promise { - if (!this.sdks.flutter) + if (!this.sdks.flutter) { + this.logger.error(`No flutter SDK!`); throw new Error("Flutter SDK not available"); + } const execution = usingCustomScript( path.join(this.sdks.flutter, flutterPath), @@ -96,6 +100,7 @@ export class BaseSdkCommands implements IAmDisposable { } protected async runCommandInFolder(shortPath: string | undefined, folder: string, binPath: string, args: string[], alwaysShowOutput: boolean): Promise { + this.logger.info(`runCommandInFolder: ${folder}, ${binPath}, ${args}`); shortPath = shortPath || path.basename(folder); const commandName = path.basename(binPath).split(".")[0]; // Trim file extension. @@ -110,6 +115,7 @@ export class BaseSdkCommands implements IAmDisposable { if (existingProcess && !existingProcess.hasStarted) { // We already have a queued version of this command so there's no value in queueing another // just bail. + this.logger.warn(`There is already a queued version of this command that has not started (${commandId}), skipping!`); return Promise.resolve(undefined); } @@ -119,13 +125,16 @@ export class BaseSdkCommands implements IAmDisposable { title: `${commandName} ${args.join(" ")}`, }, (progress, token) => { if (existingProcess) { + this.logger.info(`Terminating existing command...`); progress.report({ message: "terminating previous command..." }); existingProcess.cancel(); } else { + this.logger.info(`No existing process, will run immediately`); channel.clear(); } const process = new ChainedProcess(() => { + this.logger.info(`Starting chained process!`); channel.appendLine(`[${shortPath}] ${commandName} ${args.join(" ")}`); progress.report({ message: "running..." }); const proc = safeToolSpawn(folder, binPath, args);