Merge pull request #560 from hashicorp/refactor-session-management
refactor: change isActive to isRunning and related language to reduc…
This commit is contained in:
3 files changed
+7
-7
No files matched your search
@@ -188,7 +188,7 @@ app.on('ready', async () => {
|
||||
* Prompt for closing spawned processes
|
||||
*/
|
||||
app.on('before-quit', (event) => {
|
||||
if (sessionManager.hasActiveSessions) {
|
||||
if (sessionManager.hasRunningSessions) {
|
||||
const dialogOpts = {
|
||||
type: 'question',
|
||||
buttons: ['Close', 'Cancel'],
|
||||
|
||||
@@ -4,11 +4,11 @@ class SessionManager {
|
||||
#sessions = [];
|
||||
|
||||
/**
|
||||
* Checks for active sessions
|
||||
* Checks for running sessions
|
||||
* @returns {boolean}
|
||||
*/
|
||||
get hasActiveSessions() {
|
||||
return Boolean(this.#sessions.find((session) => session.isActive));
|
||||
get hasRunningSessions() {
|
||||
return Boolean(this.#sessions.find((session) => session.isRunning));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -36,7 +36,7 @@ class Session {
|
||||
/**
|
||||
* @return {boolean}
|
||||
*/
|
||||
get isActive() {
|
||||
get isRunning() {
|
||||
return !this.#process.killed;
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ class Session {
|
||||
*/
|
||||
stop() {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (this.isActive) {
|
||||
if (this.isRunning) {
|
||||
this.#process.on('close', () => resolve());
|
||||
this.#process.on('error', (e) => reject(e));
|
||||
this.#process.kill();
|
||||
} else {
|
||||
// Do nothing when process isn't active
|
||||
// Do nothing when process isn't running
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user