refactor: Create helpers folder in desktop/electron
This commit is contained in:
4 files changed
+2
-48
No files matched your search
@@ -1,5 +1,5 @@
|
||||
const path = require('path');
|
||||
const { spawnSync } = require('./spawn-promise');
|
||||
const { spawnSync } = require('./helpers/spawn-promise.js');
|
||||
|
||||
const cliPath = async () => path.resolve(__dirname, '..', 'cli', 'boundary');
|
||||
|
||||
|
||||
File renamed without changes.
@@ -1,6 +1,4 @@
|
||||
const { spawnAsyncJSONPromise } = require('../spawn-promise.js');
|
||||
|
||||
// FIXME create structure 'util' folder for spawn-promise
|
||||
const { spawnAsyncJSONPromise } = require('../helpers/spawn-promise.js');
|
||||
|
||||
/**
|
||||
* Super paranoid shell quote/escape and validation. Input must be base62.
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
const process = require('process');
|
||||
|
||||
const spawnedSessions = [];
|
||||
|
||||
const purge = (process_id, index) => {
|
||||
process.kill(process_id);
|
||||
// Remove tracking after cancellation
|
||||
spawnedSessions.splice(index, 1);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
/**
|
||||
* Track session spawned process and it's details.
|
||||
* This function is intended to tracked launched local proxy.
|
||||
* @param {object} params
|
||||
*/
|
||||
add: ({ childProcess, data }) => {
|
||||
spawnedSessions.push({
|
||||
data,
|
||||
process_id: childProcess.pid,
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Cancel spawned child process using session, if available.
|
||||
* This function is intended to cancel launched local proxy.
|
||||
* @param {string} session_id
|
||||
*/
|
||||
cancelSession: (session_id) => {
|
||||
spawnedSessions.find((value, index) => {
|
||||
const { process_id, data } = value;
|
||||
if (data.session_id === session_id) purge(process_id, index);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* Cancel spawned child process, if available.
|
||||
* This function is intended to cancel launched local proxy.
|
||||
* @param {string} process_id
|
||||
*/
|
||||
cancelProcess: (process_id) => {
|
||||
spawnedSessions.find((value, index) => {
|
||||
if (value.process_id === process_id) purge(process_id, index);
|
||||
});
|
||||
},
|
||||
};
|
||||
Reference in new issue
Block a user