@@ -8,31 +8,40 @@ var tooling = require('jsonforms-tooling');
88// your extension is activated the very first time the command is executed
99export function activate ( context : vscode . ExtensionContext ) {
1010
11- // Use the console to output diagnostic information (console.log) and errors (console.error)
12- // This line of code will only be executed once when your extension is activated
13- console . log ( 'Congratulations, your extension "vscode-extension" is now active!' ) ;
14-
1511 // The command has been defined in the package.json file
1612 // Now provide the implementation of the command with registerCommand
1713 // The commandId parameter must match the command field in package.json
1814 let createExampleProject = vscode . commands . registerCommand ( 'extension.createExampleProject' , ( args : any ) => {
19- // The code you place here will be executed every time your command is executed
20- let path = ( args ) ? args . fsPath : "" ;
21- tooling . cloneAndInstall ( 'example' , path ) ;
22- vscode . window . showInformationMessage ( 'Creating example project: ' + path ) ;
15+ if ( ! args ) {
16+ vscode . window . showInformationMessage ( 'You can only run this on a folder' ) ;
17+ return ;
18+ } else {
19+ let path = args . fsPath ;
20+ vscode . window . showInformationMessage ( 'Creating example project: ' + path ) ;
21+ tooling . cloneAndInstall ( 'example' , path ) ;
22+ }
2323 } ) ;
2424
2525 let createSeedProject = vscode . commands . registerCommand ( 'extension.createSeedProject' , ( args : any ) => {
26- // The code you place here will be executed every time your command is executed
27- let path = ( args ) ? args . fsPath : "" ;
28- tooling . cloneAndInstall ( 'seed' , path ) ;
29- vscode . window . showInformationMessage ( 'Creating seed project: ' + path ) ;
26+ if ( ! args ) {
27+ vscode . window . showInformationMessage ( 'You can only run this on a folder' ) ;
28+ return ;
29+ } else {
30+ let path = args . fsPath ;
31+ vscode . window . showInformationMessage ( 'Creating seed project: ' + path ) ;
32+ tooling . cloneAndInstall ( 'seed' , path ) ;
33+ }
3034 } ) ;
3135
3236 let generateUISchema = vscode . commands . registerCommand ( 'extension.generateUISchema' , ( args : any ) => {
33- let path = ( args ) ? args . fsPath : "" ;
34- tooling . generateUISchema ( path ) ;
35- vscode . window . showInformationMessage ( 'Generating UI Schema: ' + path ) ;
37+ if ( ! args ) {
38+ vscode . window . showInformationMessage ( 'You can only run this on a json file' ) ;
39+ return ;
40+ } else {
41+ let path = args . fsPath ;
42+ vscode . window . showInformationMessage ( 'Generating UI Schema: ' + path ) ;
43+ tooling . generateUISchema ( path ) ;
44+ }
3645 } ) ;
3746
3847 context . subscriptions . push ( createExampleProject ) ;
0 commit comments