Skip to content

Commit

Permalink
#4 - Add name option for ui-schema.json file
Browse files Browse the repository at this point in the history
  • Loading branch information
TheZoker committed Nov 19, 2018
1 parent 8077ea5 commit 8166f14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tooling/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function cloneAndInstall(repo: String, path: string, callback: (result: s
* @param {string} path path to the json schema file
* @param {function} callback forwards the current status to the caller
*/
export function generateUISchema(path: string, callback: (result: string, type?: string) => void) {
export function generateUISchema(path: string, name: string, callback: (result: string, type?: string) => void) {
// Read JSON Schema file
readFile(path, 'utf8', (err, data) => {
if (err) {
Expand All @@ -59,9 +59,9 @@ export function generateUISchema(path: string, callback: (result: string, type?:

// Check if windows or linux filesystem
if(process.platform === 'win32') {
var newPath = path.substring(0, path.lastIndexOf("\\"))+'\\ui-schema.json';
var newPath = path.substring(0, path.lastIndexOf("\\"))+'\\'+name;
} else {
var newPath = path.substring(0, path.lastIndexOf("/"))+'/ui-schema.json';
var newPath = path.substring(0, path.lastIndexOf("/"))+'/'+name;
}

// Write UI Schema file
Expand Down
14 changes: 11 additions & 3 deletions vscode-extension/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ export function activate(context: vscode.ExtensionContext) {
return;
} else {
let path = args.fsPath;
showMessage('Generating UI Schema: '+path);
tooling.generateUISchema(path, function(result: string, type: string) {
showMessage(result, type);

let options: vscode.InputBoxOptions = {
prompt: "Label: ",
placeHolder: "Enter a filename for your UI Schema (default: ui-schema.json)"
}
vscode.window.showInputBox(options).then(name => {
if (!name) name = 'ui-schema.json';
showMessage('Generating UI Schema: '+path);
tooling.generateUISchema(path, name, function(result: string, type: string) {
showMessage(result, type);
});
});
}
});
Expand Down

0 comments on commit 8166f14

Please sign in to comment.