@@ -8,31 +8,40 @@ var tooling = require('jsonforms-tooling');
8
8
// your extension is activated the very first time the command is executed
9
9
export function activate ( context : vscode . ExtensionContext ) {
10
10
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
-
15
11
// The command has been defined in the package.json file
16
12
// Now provide the implementation of the command with registerCommand
17
13
// The commandId parameter must match the command field in package.json
18
14
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
+ }
23
23
} ) ;
24
24
25
25
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
+ }
30
34
} ) ;
31
35
32
36
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
+ }
36
45
} ) ;
37
46
38
47
context . subscriptions . push ( createExampleProject ) ;
0 commit comments