You've already forked Tricky-Addon-Update-Target-List
mirror of
https://github.com/KOWX712/Tricky-Addon-Update-Target-List.git
synced 2025-09-06 06:37:09 +00:00
opt: use ksu.spawn for long script
This commit is contained in:
@@ -41,6 +41,27 @@ export function exec(command, options = {}) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Standard I/O stream for a child process.
|
||||
* @class
|
||||
*/
|
||||
class Stdio {
|
||||
constructor() {
|
||||
this.listeners = {};
|
||||
}
|
||||
on(event, listener) {
|
||||
if (!this.listeners[event]) {
|
||||
this.listeners[event] = [];
|
||||
}
|
||||
this.listeners[event].push(listener);
|
||||
}
|
||||
emit(event, ...args) {
|
||||
if (this.listeners[event]) {
|
||||
this.listeners[event].forEach(listener => listener(...args));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Spawn shell process with ksu.spawn
|
||||
* @param {string} command - The command to execute
|
||||
@@ -71,20 +92,6 @@ export function spawn(command, args = [], options = {}) {
|
||||
}
|
||||
}
|
||||
};
|
||||
function Stdio() {
|
||||
this.listeners = {};
|
||||
}
|
||||
Stdio.prototype.on = function(event, listener) {
|
||||
if (!this.listeners[event]) {
|
||||
this.listeners[event] = [];
|
||||
}
|
||||
this.listeners[event].push(listener);
|
||||
};
|
||||
Stdio.prototype.emit = function(event, ...args) {
|
||||
if (this.listeners[event]) {
|
||||
this.listeners[event].forEach(listener => listener(...args));
|
||||
}
|
||||
};
|
||||
const callbackName = getUniqueCallbackName("spawn");
|
||||
window[callbackName] = child;
|
||||
child.on("exit", () => delete window[callbackName]);
|
||||
|
||||
Reference in New Issue
Block a user