@@ -15,7 +15,7 @@ export const commandWrapper = (command: () => Promise<void> | void) => {
1515 if ( error instanceof ExtensionError ) {
1616 vscode . window . showErrorMessage ( error . message ) ;
1717 } else if ( error instanceof Error ) {
18- vscode . window . showErrorMessage ( "An error has occurred" ) ;
18+ vscode . window . showErrorMessage ( "An error has occurred. " ) ;
1919 console . error ( error ) ;
2020 }
2121 }
@@ -33,7 +33,7 @@ export const getWorkspaceFolder = async () => {
3333 const workspaceFolders = vscode . workspace . workspaceFolders ;
3434
3535 if ( ! workspaceFolders ) {
36- throw new FatalExtensionError ( "Open a workspace to swap tsconfig" ) ;
36+ throw new FatalExtensionError ( "Open a workspace to swap tsconfig. " ) ;
3737 } else if ( workspaceFolders . length === 1 ) {
3838 return workspaceFolders [ 0 ] ;
3939 } else {
@@ -44,11 +44,19 @@ export const getWorkspaceFolder = async () => {
4444
4545export const getTsconfigFiles = ( path : string ) => {
4646 const getPatternPath = ( pattern : string ) => posix . join ( path , pattern ) ;
47- const config = vscode . workspace . getConfiguration ( "swap-tsconfig" ) ;
48- const include = config . include . map ( getPatternPath ) ;
49- const exclude = config . exclude . map ( getPatternPath ) ;
47+ const settings = vscode . workspace . getConfiguration ( "swap-tsconfig" ) ;
48+ const include = settings . include . map ( getPatternPath ) ;
49+ const exclude = settings . exclude . map ( getPatternPath ) ;
5050
51- return globSync ( include , { ignore : exclude } )
51+ const tsconfigFiles = globSync ( include , { ignore : exclude } )
5252 . map ( ( tsconfigFile ) => posix . relative ( path , tsconfigFile ) )
5353 . sort ( ( a , b ) => a . length - b . length ) ;
54+
55+ if ( ! tsconfigFiles . length ) {
56+ throw new FatalExtensionError (
57+ "No tsconfig files found. Ensure the 'exclude' and 'include' settings for this extension are correctly configured." ,
58+ ) ;
59+ }
60+
61+ return tsconfigFiles ;
5462} ;
0 commit comments