- Updated import paths for types and utilities in config-service, menu-service, script-execution-service, script-store-service, and window-service to reflect new structure. - Moved utility functions like debounce and cloneDeep to shared utilities. - Created new runtime and script types files to centralize type definitions. - Removed deprecated task-types and locale messages files. - Updated constants to use shared definitions and added new placeholders for providers. - Enhanced provider type information with additional placeholders for different languages.
38 lines
865 B
TypeScript
38 lines
865 B
TypeScript
import { executeScriptService } from '@electron/service/execute-script-service';
|
|
import {
|
|
getScriptPathById,
|
|
updateLastRun,
|
|
} from '@electron/service/script-store-service';
|
|
import type { ScriptExecutionResult } from '../../types/script-types';
|
|
|
|
const executor = new executeScriptService();
|
|
|
|
export async function runScriptById(
|
|
id: string,
|
|
channel?: string,
|
|
): Promise<ScriptExecutionResult> {
|
|
const scriptPath = getScriptPathById(id);
|
|
if (!scriptPath) {
|
|
return {
|
|
success: false,
|
|
exitCode: null,
|
|
stdoutTail: '',
|
|
stderrTail: '',
|
|
error: 'Script not found',
|
|
};
|
|
}
|
|
|
|
const result = await executor.executeScript(scriptPath, {
|
|
SCRIPT_ID: id,
|
|
CHANNEL: channel || '',
|
|
});
|
|
|
|
updateLastRun(id, {
|
|
time: new Date().toISOString(),
|
|
success: result.success,
|
|
error: result.error,
|
|
});
|
|
|
|
return result;
|
|
}
|