Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaliy-guliy committed Dec 24, 2019
1 parent 5890ff9 commit 69fb4e4
Showing 1 changed file with 26 additions and 39 deletions.
65 changes: 26 additions & 39 deletions src/yeoman-process-adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export class YeomanProcessAdapter {
const child = fork(process, params, options);

child.on('message', this.onMessage);
// child.on('close', this.onClose);
// child.on('exit', this.onExit);

child.stdout.on('data', (data: any) => {
console.log(`## stdout: ${data}`);
Expand Down Expand Up @@ -104,32 +102,39 @@ export class YeomanProcessAdapter {
}
}

// private onClose = async (code: any) => {
// console.log(`child process close all stdio with code ${code}`);
// }

// private onExit = async (code: any) => {
// console.log(`child process exited with code ${code}`);
// }

/**
* Prints to the Yeoman generator output view by request from Yeoman Generator.
* Prints a message to the Yeoman generator output view.
*
* @param msg
* @param msg object containing message and message prefix
*/
protected processOutput(msg: any) {
this.outputChannel.append(msg.prefix);
this.outputChannel.appendLine(msg.message);
}

/**
* Displays an information notification.
*
* @param msg object containing message to be displayed
*/
protected processInformationMessage(msg: any) {
theia.window.showInformationMessage(msg.message);
}

/**
* Displays an error notification.
*
* @param msg object containing message to be displayed
*/
protected processErrorMessage(msg: any) {
theia.window.showErrorMessage(msg.message);
}

/**
* Displays prompt popup.
*
* @param msg object containing prompt params
*/
protected processPrompt(msg: any) {
const question = msg.question;

Expand All @@ -140,6 +145,9 @@ export class YeomanProcessAdapter {
}
}

/**
* Displays quick pick menu continint list of answers.
*/
private askQuestion(question: any, promiseId: number) {
const replies: any = {};

Expand All @@ -156,8 +164,6 @@ export class YeomanProcessAdapter {
detail: choice.detail ? choice.detail : undefined,
value: choice.value ? choice.value : undefined
};

console.log('## CHOISE ' + choice.name + ' : ' + choice.value);
quickPickItems.push(item);
});

Expand All @@ -167,22 +173,13 @@ export class YeomanProcessAdapter {

theia.window.showQuickPick(quickPickItems, options).then((pickedItem: theia.QuickPickItem | undefined) => {
replies[question.name] = (pickedItem as CustomQuickPickItem).value;

console.log('>>>> ON REPLY!! Value: ' + replies[question.name]);

this.reply(promiseId, replies);

// if (pickedItem !== undefined && resolve !== undefined && resolve !== {}) {
// callback(replies);
// resolve(replies);
// } else {
// this.askQuestion(question, replies, resolve, reject, callback);
// }
}, rejectReason => {
console.log('!!!!!!!!!!!!! REJECTED ', rejectReason);
});
}

/**
* Displays input popup.
*/
private askValue(question: any, promiseId: number) {
const replies: any = {};

Expand All @@ -197,32 +194,22 @@ export class YeomanProcessAdapter {
value: defaultValue
};

console.log('### INPUT OPTION: ', inputOption);

theia.window.showInputBox(inputOption).then((s: string | undefined) => {
if (typeof s !== 'undefined') {
replies[question.name] = s;
} else {
replies[question.name] = defaultValue;
}

console.log('>>>> ON REPLY!! Value: ' + replies[question.name]);

this.reply(promiseId, replies);

// callback(replies);
// resolve(replies);
}, rejectReason => {
console.log('!!!!!!!!!!!!! REJECTED ', rejectReason);
});

}

/**
* Replies to the client on prompt request.
*/
private reply(promiseId: number, replies: any) {
console.log('>> REPLY: ', replies);

if (this.childProcess && this.childProcess.send) {
// this.childProcess.send('hello, client!');
this.childProcess.send({
action: 'reply',
promiseId: promiseId,
Expand Down

0 comments on commit 69fb4e4

Please sign in to comment.