Skip to content

Commit

Permalink
Hey
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartik Raj committed Oct 20, 2023
1 parent d805e48 commit a52599f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import { inject, injectable } from 'inversify';
import { Position, Uri, WorkspaceEdit, Range, TextEditorRevealType, ProgressLocation } from 'vscode';
import { createFile } from 'fs-extra';
import { IApplicationEnvironment, IApplicationShell, IDocumentManager } from '../../common/application/types';
import { IDisposableRegistry, IExperimentService, IPersistentStateFactory } from '../../common/types';
import { Common, Interpreters } from '../../common/utils/localize';
Expand All @@ -19,7 +18,7 @@ import { sleep } from '../../common/utils/async';
import { getDeactivateShellInfo } from './deactivateScripts';
import { isTestExecution } from '../../common/constants';
import { ProgressService } from '../../common/application/progressService';
import { copyFile, pathExists } from '../../common/platform/fs-paths';
import { copyFile, createFile, pathExists } from '../../common/platform/fs-paths';
import { getOSType, OSType } from '../../common/utils/platform';

export const terminalDeactivationPromptKey = 'TERMINAL_DEACTIVATION_PROMPT_KEY';
Expand Down Expand Up @@ -139,7 +138,7 @@ ${content}

private async openScript(command: string) {
const initScriptPath = await this.getPathToScript(command);
if (await pathExists(initScriptPath)) {
if (!(await pathExists(initScriptPath))) {
await createFile(initScriptPath);
}
const document = await this.documentManager.openTextDocument(initScriptPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,21 @@ suite('Terminal Deactivation Limitation Prompt', () => {
when(notificationEnabled.value).thenReturn(true);
when(shell.showWarningMessage(expectedMessage, ...prompts)).thenReturn(Promise.resolve(prompts[0]));
let fileCopied = false;
let createdFile = false;
sinon.stub(fsapi, 'copyFile').callsFake(async (_src: string, _dest: string) => {
fileCopied = true;
Promise.resolve();
});
sinon.stub(fsapi, 'pathExists').callsFake(async (p: string) => {
if (p === initScriptPath) {
return Promise.resolve(false);
}
return Promise.resolve(true);
});
sinon.stub(fsapi, 'createFile').callsFake(async (_: string) => {
createdFile = true;
return Promise.resolve();
});
when(shell.withProgress(anything(), anything())).thenResolve();
const editor = mock<TextEditor>();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand All @@ -221,6 +232,7 @@ suite('Terminal Deactivation Limitation Prompt', () => {
await deactivatePrompt._notifyUsers(TerminalShellType.bash);

expect(fileCopied).to.equal(true);
expect(createdFile).to.equal(true, 'File not created');
verify(shell.withProgress(anything(), anything())).once();
verify(shell.showWarningMessage(expectedMessage, ...prompts)).once();
verify(notificationEnabled.updateValue(false)).once();
Expand Down

0 comments on commit a52599f

Please sign in to comment.