11import * as vscode from 'vscode' ;
2- const path = require ( 'path' ) ;
2+ import * as path from 'path' ;
33import * as fs from 'fs' ;
44import * as _ from 'lodash' ;
55
6- function GetTemplates ( templatePath : fs . PathLike ) : Array < Array < string > > {
6+ export function GetTemplates ( templatePath : fs . PathLike ) : Array < Array < string > > {
77 const files = fs . readdirSync ( templatePath ) ;
88 const templates : Array < string > = [ ] ;
99 files . filter ( e => e . includes ( ".dockerignore" ) ? false : true ) . forEach ( file => {
@@ -12,14 +12,28 @@ function GetTemplates(templatePath: fs.PathLike): Array<Array<string>> {
1212 return [ templates , files ] ;
1313}
1414
15- function CreateDockerFile ( option : any , templatePath : String , workspaceFolder : String ) : void {
16- const data = fs . readFileSync ( `${ templatePath } /${ option } .dockerfile` ) ;
17- fs . writeFileSync ( `${ workspaceFolder } /Dockerfile` , data ) ;
15+ export function CreateDockerFile ( option : any , templatePath : String , workspaceFolder : String ) : Boolean {
16+ try {
17+ const data = fs . readFileSync ( `${ templatePath } /${ option } .dockerfile` ) ;
18+ fs . writeFileSync ( `${ workspaceFolder } /Dockerfile` , data ) ;
19+ } catch ( error ) {
20+ return false
21+ }
22+ finally {
23+ return true
24+ }
1825}
1926
20- function CreateIgnoreDockerFile ( option : any , templatePath : String , workspaceFolder : String ) : void {
21- const data = fs . readFileSync ( `${ templatePath } /.dockerignore ${ option } ` ) ;
22- fs . writeFileSync ( `${ workspaceFolder } /.dockerignore` , data ) ;
27+ export function CreateIgnoreDockerFile ( option : any , templatePath : String , workspaceFolder : String ) : Boolean {
28+ try {
29+ const data = fs . readFileSync ( `${ templatePath } /.dockerignore ${ option } ` ) ;
30+ fs . writeFileSync ( `${ workspaceFolder } /.dockerignore` , data ) ;
31+ } catch ( error ) {
32+ return false
33+ }
34+ finally {
35+ return true
36+ }
2337}
2438
2539export function activate ( context : vscode . ExtensionContext ) {
@@ -45,9 +59,9 @@ export function activate(context: vscode.ExtensionContext) {
4559 }
4660 else {
4761 vscode . window . showInformationMessage ( "workspaceFolder not found" )
48- }
62+ }
4963 } )
5064 context . subscriptions . push ( disposable ) ;
5165}
5266
53- export function deactivate ( ) { }
67+ export function deactivate ( ) { }
0 commit comments