@@ -17,7 +17,7 @@ import { fs } from '../../shared/fs/fs'
1717import { CodeWhispererConstants } from '../../codewhisperer/indexNode'
1818import { CurrentWsFolders , defaultExcludePatterns } from '../../shared/utilities/workspaceUtils'
1919import { TestFolder } from '../testUtil'
20- import { NoActiveFileError } from '../../codewhisperer/models/errors'
20+ import { NoActiveFileError , NoSourceFilesError } from '../../codewhisperer/models/errors'
2121
2222describe ( 'zipUtil' , function ( ) {
2323 const workspaceFolder = getTestWorkspaceFolder ( )
@@ -231,4 +231,36 @@ describe('zipUtil', function () {
231231
232232 assert . strictEqual ( zipMetadata . language , 'typescript' )
233233 } )
234+
235+ it ( 'able to process files outside of workspace' , async function ( ) {
236+ const project = await TestFolder . create ( )
237+ const fileName = 'thisIsPartOfMyProject.py'
238+ await project . write ( fileName , 'file1' )
239+ const filepath = path . join ( project . path , fileName )
240+ await vscode . window . showTextDocument ( vscode . Uri . parse ( filepath ) )
241+ const zipMetadata = await zipUtil . zipProject (
242+ [ ...( vscode . workspace . workspaceFolders ?? [ ] ) ] as CurrentWsFolders ,
243+ defaultExcludePatterns ,
244+ {
245+ includeNonWorkspaceFiles : true ,
246+ }
247+ )
248+
249+ assert . strictEqual ( zipMetadata . scannedFiles . has ( path . join ( project . path , fileName ) ) , true )
250+ } )
251+
252+ it ( 'throws on empty project' , async function ( ) {
253+ const project = await TestFolder . create ( )
254+ await assert . rejects (
255+ async ( ) =>
256+ await zipUtil . zipProject (
257+ [ { uri : vscode . Uri . file ( project . path ) , name : 'project1' , index : 0 } ] as CurrentWsFolders ,
258+ defaultExcludePatterns ,
259+ {
260+ includeNonWorkspaceFiles : true ,
261+ }
262+ ) ,
263+ new NoSourceFilesError ( )
264+ )
265+ } )
234266} )
0 commit comments