@@ -2,15 +2,15 @@ import * as vscode from 'vscode';
22import { StatusBarItems } from './interface' ;
33import { join , resolve } from 'path' ;
44import { platform } from 'os' ;
5- import { existsSync , mkdirSync , readdirSync , writeFile , statSync } from 'fs' ;
6- import { gitignore , maincpp , makefile , readme } from './templates'
5+ import { existsSync , mkdirSync , readdirSync , writeFile , statSync , Stats } from 'fs' ;
6+ import { gitignore , maincpp , makefile , readme } from './templates' ;
77
88export class CodeManage {
99
1010 private _terminal : vscode . Terminal ;
1111 private _folderPath : string ;
1212 private _items : StatusBarItems ;
13- private _watcher : vscode . FileSystemWatcher | null
13+ private _watcher : vscode . FileSystemWatcher | null ;
1414
1515 constructor ( ) {
1616
@@ -22,7 +22,7 @@ export class CodeManage {
2222 this . _items = {
2323 create : vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right ) ,
2424 start : vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right ) ,
25- }
25+ } ;
2626 this . _watcher = null ;
2727 this . setupFileSystemWatcher ( ) ;
2828 this . updateStatusBar ( ) ;
@@ -35,13 +35,13 @@ export class CodeManage {
3535
3636 try {
3737
38- const binStats = statSync ( binPath ) ;
38+ const binStats : Stats = statSync ( binPath ) ;
3939
4040 if ( ! binStats . isDirectory ( ) ) {
4141 this . build ( ) ;
4242 } else {
43- const files = readdirSync ( binPath ) ;
44- if ( files . length == 0 ) {
43+ const files : string [ ] = readdirSync ( binPath ) ;
44+ if ( files . length === 0 ) {
4545 this . build ( ) ;
4646 } else {
4747 this . build ( ) ;
@@ -76,7 +76,7 @@ export class CodeManage {
7676 'tests'
7777 ] ;
7878
79- folders . forEach ( ( folder ) => this . createFolder ( this . _folderPath , folder ) ) ;
79+ folders . forEach ( ( folder : string ) => this . createFolder ( this . _folderPath , folder ) ) ;
8080
8181 this . createFile ( join ( this . _folderPath , 'src' , 'main.cpp' ) , maincpp ) ;
8282 this . createFile ( join ( this . _folderPath , '.gitignore' ) , gitignore ) ;
@@ -153,7 +153,7 @@ export class CodeManage {
153153 this . _terminal . sendText ( `${ command } ` ) ;
154154
155155 } catch ( e : any ) {
156- vscode . window . showErrorMessage ( e ) ;
156+ vscode . window . showErrorMessage ( e . message || e . toString ( ) ) ;
157157 }
158158
159159 }
@@ -175,12 +175,11 @@ export class CodeManage {
175175 private createFile ( filePath : string , templatePath : string ) {
176176
177177 if ( ! existsSync ( filePath ) ) {
178- writeFile ( filePath , templatePath , 'utf8' , ( err ) => {
178+ writeFile ( filePath , templatePath , 'utf8' , ( err : NodeJS . ErrnoException | null ) => {
179179 if ( err ) {
180- console . error ( err )
181180 vscode . window . showErrorMessage ( 'Failed to create file' ) ;
182181 }
183- } )
182+ } ) ;
184183 }
185184
186185 }
0 commit comments