Skip to content

Commit 4e9d959

Browse files
committed
Merge branch 'removeFsExtra' into removeFsExtra2
2 parents 4213161 + e9e7760 commit 4e9d959

File tree

3 files changed

+39
-39
lines changed

3 files changed

+39
-39
lines changed

packages/core/src/amazonq/commons/diff.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
import { existsSync } from 'fs'
76
import * as vscode from 'vscode'
87
import { featureDevScheme } from '../../amazonqFeatureDev/constants'
8+
import { fs } from '../../shared'
99

1010
export async function openDiff(leftPath: string, rightPath: string, tabId: string) {
11-
const { left, right } = getFileDiffUris(leftPath, rightPath, tabId)
11+
const { left, right } = await getFileDiffUris(leftPath, rightPath, tabId)
1212
await vscode.commands.executeCommand('vscode.diff', left, right)
1313
}
1414

1515
export async function openDeletedDiff(filePath: string, name: string, tabId: string) {
16-
const fileUri = getOriginalFileUri(filePath, tabId)
16+
const fileUri = await getOriginalFileUri(filePath, tabId)
1717
await vscode.commands.executeCommand('vscode.open', fileUri, {}, `${name} (Deleted)`)
1818
}
1919

20-
export function getOriginalFileUri(fullPath: string, tabId: string) {
21-
return existsSync(fullPath) ? vscode.Uri.file(fullPath) : createAmazonQUri('empty', tabId)
20+
export async function getOriginalFileUri(fullPath: string, tabId: string) {
21+
return (await fs.exists(fullPath)) ? vscode.Uri.file(fullPath) : createAmazonQUri('empty', tabId)
2222
}
2323

24-
export function getFileDiffUris(leftPath: string, rightPath: string, tabId: string) {
25-
const left = getOriginalFileUri(leftPath, tabId)
24+
export async function getFileDiffUris(leftPath: string, rightPath: string, tabId: string) {
25+
const left = await getOriginalFileUri(leftPath, tabId)
2626
const right = createAmazonQUri(rightPath, tabId)
2727

2828
return { left, right }

packages/core/src/test/amazonq/common/diff.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
import assert from 'assert'
1212
import * as path from 'path'
1313
import * as vscode from 'vscode'
14-
import fs from 'fs'
1514
import sinon from 'sinon'
1615
import { createAmazonQUri, getFileDiffUris, getOriginalFileUri, openDeletedDiff, openDiff } from '../../../amazonq'
16+
import { FileSystem } from '../../../shared/fs/fs'
1717

1818
describe('diff', () => {
1919
const filePath = path.join('/', 'foo', 'fi')
@@ -35,7 +35,7 @@ describe('diff', () => {
3535

3636
describe('openDiff', () => {
3737
it('file exists locally', async () => {
38-
sandbox.stub(fs, 'existsSync').returns(true)
38+
sandbox.stub(FileSystem.prototype, 'exists').resolves(true)
3939
await openDiff(filePath, rightPath, tabId)
4040

4141
const leftExpected = vscode.Uri.file(filePath)
@@ -44,10 +44,10 @@ describe('diff', () => {
4444
})
4545

4646
it('file does not exists locally', async () => {
47-
sandbox.stub(fs, 'existsSync').returns(false)
47+
sandbox.stub(FileSystem.prototype, 'exists').resolves(false)
4848
await openDiff(filePath, rightPath, tabId)
4949

50-
const leftExpected = getOriginalFileUri(filePath, tabId)
50+
const leftExpected = await getOriginalFileUri(filePath, tabId)
5151
const rightExpected = createAmazonQUri(rightPath, tabId)
5252
assert.ok(executeCommandSpy.calledWith('vscode.diff', leftExpected, rightExpected))
5353
})
@@ -57,15 +57,15 @@ describe('diff', () => {
5757
const name = 'foo'
5858

5959
it('file exists locally', async () => {
60-
sandbox.stub(fs, 'existsSync').returns(true)
60+
sandbox.stub(FileSystem.prototype, 'exists').resolves(true)
6161
await openDeletedDiff(filePath, name, tabId)
6262

6363
const expectedPath = vscode.Uri.file(filePath)
6464
assert.ok(executeCommandSpy.calledWith('vscode.open', expectedPath, {}, `${name} (Deleted)`))
6565
})
6666

6767
it('file does not exists locally', async () => {
68-
sandbox.stub(fs, 'existsSync').returns(false)
68+
sandbox.stub(FileSystem.prototype, 'exists').resolves(false)
6969
await openDeletedDiff(filePath, name, tabId)
7070

7171
const expectedPath = createAmazonQUri('empty', tabId)
@@ -74,23 +74,23 @@ describe('diff', () => {
7474
})
7575

7676
describe('getOriginalFileUri', () => {
77-
it('file exists locally', () => {
78-
sandbox.stub(fs, 'existsSync').returns(true)
79-
assert.deepStrictEqual(getOriginalFileUri(filePath, tabId).fsPath, filePath)
77+
it('file exists locally', async () => {
78+
sandbox.stub(FileSystem.prototype, 'exists').resolves(true)
79+
assert.deepStrictEqual((await getOriginalFileUri(filePath, tabId)).fsPath, filePath)
8080
})
8181

82-
it('file does not exists locally', () => {
83-
sandbox.stub(fs, 'existsSync').returns(false)
82+
it('file does not exists locally', async () => {
83+
sandbox.stub(FileSystem.prototype, 'exists').resolves(false)
8484
const expected = createAmazonQUri('empty', tabId)
85-
assert.deepStrictEqual(getOriginalFileUri(filePath, tabId), expected)
85+
assert.deepStrictEqual(await getOriginalFileUri(filePath, tabId), expected)
8686
})
8787
})
8888

8989
describe('getFileDiffUris', () => {
90-
it('file exists locally', () => {
91-
sandbox.stub(fs, 'existsSync').returns(true)
90+
it('file exists locally', async () => {
91+
sandbox.stub(FileSystem.prototype, 'exists').resolves(true)
9292

93-
const { left, right } = getFileDiffUris(filePath, rightPath, tabId)
93+
const { left, right } = await getFileDiffUris(filePath, rightPath, tabId)
9494

9595
const leftExpected = vscode.Uri.file(filePath)
9696
assert.deepStrictEqual(left, leftExpected)
@@ -99,11 +99,11 @@ describe('diff', () => {
9999
assert.deepStrictEqual(right, rightExpected)
100100
})
101101

102-
it('file does not exists locally', () => {
103-
sandbox.stub(fs, 'existsSync').returns(false)
104-
const { left, right } = getFileDiffUris(filePath, rightPath, tabId)
102+
it('file does not exists locally', async () => {
103+
sandbox.stub(FileSystem.prototype, 'exists').resolves(false)
104+
const { left, right } = await getFileDiffUris(filePath, rightPath, tabId)
105105

106-
const leftExpected = getOriginalFileUri(filePath, tabId)
106+
const leftExpected = await getOriginalFileUri(filePath, tabId)
107107
assert.deepStrictEqual(left, leftExpected)
108108

109109
const rightExpected = createAmazonQUri(rightPath, tabId)

packages/core/src/test/techdebt.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import * as env from '../shared/vscode/env'
1010
// Checks project config and dependencies, to remind us to remove old things
1111
// when possible.
1212
describe('tech debt', function () {
13-
// function fixByDate(date: string, msg: string) {
14-
// const now = Date.now()
15-
// const cutoffDate = Date.parse(date)
16-
// assert.ok(now <= cutoffDate, msg)
17-
// }
13+
function fixByDate(date: string, msg: string) {
14+
const now = Date.now()
15+
const cutoffDate = Date.parse(date)
16+
assert.ok(now <= cutoffDate, msg)
17+
}
1818

1919
it('vscode minimum version', async function () {
2020
const minVscode = env.getMinVscodeVersion()
@@ -46,13 +46,13 @@ describe('tech debt', function () {
4646
)
4747
})
4848

49-
// it('remove separate sessions login edge cases', async function () {
50-
// // src/auth/auth.ts:SessionSeparationPrompt
51-
// // forgetConnection() function and calls
49+
it('remove separate sessions login edge cases', async function () {
50+
// src/auth/auth.ts:SessionSeparationPrompt
51+
// forgetConnection() function and calls
5252

53-
// // Monitor telemtry to determine removal or snooze
54-
// // toolkit_showNotification.id = sessionSeparation
55-
// // auth_modifyConnection.action = deleteProfile OR auth_modifyConnection.source contains CodeCatalyst
56-
// fixByDate('2024-9-30', 'Remove the edge case code from the commit that this test is a part of.')
57-
// })
53+
// Monitor telemtry to determine removal or snooze
54+
// toolkit_showNotification.id = sessionSeparation
55+
// auth_modifyConnection.action = deleteProfile OR auth_modifyConnection.source contains CodeCatalyst
56+
fixByDate('2024-10-30', 'Remove the edge case code from the commit that this test is a part of.')
57+
})
5858
})

0 commit comments

Comments
 (0)