Skip to content

Commit ca8d03a

Browse files
authored
1 parent d0c07e4 commit ca8d03a

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

src/features/terminal/shells/cmd/cmdStartup.ts

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ import { ShellConstants } from '../../../common/shellConstants';
1010
import { hasStartupCode, insertStartupCode, removeStartupCode } from '../common/editUtils';
1111
import { ShellScriptEditState, ShellSetupState, ShellStartupScriptProvider } from '../startupProvider';
1212
import { CMD_ENV_KEY, CMD_SCRIPT_VERSION } from './cmdConstants';
13+
import { StopWatch } from '../../../../common/stopWatch';
1314

14-
const exec = promisify(cp.exec);
15+
function execCommand(command: string) {
16+
const timer = new StopWatch();
17+
return promisify(cp.exec)(command, { windowsHide: true }).finally(() =>
18+
traceInfo(`Executed command: ${command} in ${timer.elapsedTime}`),
19+
);
20+
}
1521

1622
async function isCmdInstalled(): Promise<boolean> {
1723
if (!isWindows()) {
@@ -94,9 +100,7 @@ async function checkRegistryAutoRun(mainBatchFile: string, regMainBatchFile: str
94100

95101
try {
96102
// Check if AutoRun is set in the registry to call our batch file
97-
const { stdout } = await exec('reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun', {
98-
windowsHide: true,
99-
});
103+
const { stdout } = await execCommand('reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun');
100104

101105
// Check if the output contains our batch file path
102106
return stdout.includes(regMainBatchFile) || stdout.includes(mainBatchFile);
@@ -112,9 +116,7 @@ async function getExistingAutoRun(): Promise<string | undefined> {
112116
}
113117

114118
try {
115-
const { stdout } = await exec('reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun', {
116-
windowsHide: true,
117-
});
119+
const { stdout } = await execCommand('reg query "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun');
118120

119121
const match = stdout.match(/AutoRun\s+REG_SZ\s+(.*)/);
120122
if (match && match[1]) {
@@ -135,9 +137,8 @@ async function setupRegistryAutoRun(mainBatchFile: string): Promise<boolean> {
135137

136138
try {
137139
// Set the registry key to call our main batch file
138-
await exec(
140+
await execCommand(
139141
`reg add "HKCU\\Software\\Microsoft\\Command Processor" /v AutoRun /t REG_SZ /d "if exist \\"${mainBatchFile}\\" call \\"${mainBatchFile}\\"" /f`,
140-
{ windowsHide: true },
141142
);
142143

143144
traceInfo(

src/features/terminal/shells/utils.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
import * as cp from 'child_process';
2-
import { traceVerbose } from '../../../common/logging';
2+
import { traceError, traceInfo } from '../../../common/logging';
3+
import { StopWatch } from '../../../common/stopWatch';
34

45
export async function runCommand(command: string): Promise<string | undefined> {
56
return new Promise((resolve) => {
7+
const timer = new StopWatch();
68
cp.exec(command, (err, stdout) => {
79
if (err) {
8-
traceVerbose(`Error running command: ${command}`, err);
10+
traceError(`Error running command: ${command} (${timer.elapsedTime})`, err);
911
resolve(undefined);
1012
} else {
13+
traceInfo(`Ran ${command} in ${timer.elapsedTime}`);
1114
resolve(stdout?.trim());
1215
}
1316
});

src/managers/builtin/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export async function isUvInstalled(log?: LogOutputChannel): Promise<boolean> {
99
if (available.completed) {
1010
return available.promise;
1111
}
12-
12+
log?.info(`Running: uv --version`);
1313
const proc = ch.spawn('uv', ['--version']);
1414
proc.on('error', () => {
1515
available.resolve(false);

src/managers/conda/condaUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import { Installable } from '../common/types';
5656
import { shortVersion, sortEnvironments } from '../common/utils';
5757
import { CondaEnvManager } from './condaEnvManager';
5858
import { getCondaHookPs1Path, getLocalActivationScript } from './condaSourcingUtils';
59+
import { StopWatch } from '../../common/stopWatch';
5960

6061
export const CONDA_PATH_KEY = `${ENVS_EXTENSION_ID}:conda:CONDA_PATH`;
6162
export const CONDA_PREFIXES_KEY = `${ENVS_EXTENSION_ID}:conda:CONDA_PREFIXES`;
@@ -202,6 +203,8 @@ async function _runConda(
202203
): Promise<string> {
203204
const deferred = createDeferred<string>();
204205
args = quoteArgs(args);
206+
const timer = new StopWatch();
207+
deferred.promise.finally(() => traceInfo(`Ran conda in ${timer.elapsedTime}: ${conda} ${args.join(' ')}`));
205208
const proc = ch.spawn(conda, args, { shell: true });
206209

207210
token?.onCancellationRequested(() => {

0 commit comments

Comments
 (0)