MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / enableScript

Method enableScript

src/app/service/sandbox/runtime.ts:90–113  ·  view source on GitHub ↗
(script: ScriptRunResource)

Source from the content-addressed store, hash-verified

88 }
89
90 async enableScript(script: ScriptRunResource) {
91 // 开启脚本
92 // 如果正在运行,先释放
93 if (this.execScriptMap.has(script.uuid)) {
94 await this.disableScript(script.uuid);
95 }
96 const metadataStr = getMetadataStr(script.code) || "";
97 const userConfigStr = getUserConfigStr(script.code) || "";
98 const userConfig = parseUserConfig(userConfigStr);
99 const loadScript = {
100 ...script,
101 metadataStr,
102 userConfigStr,
103 userConfig,
104 } as ScriptLoadInfo;
105 if (script.type === SCRIPT_TYPE_BACKGROUND) {
106 // 后台脚本直接运行起来
107 return this.execScript(loadScript);
108 } else {
109 // 定时脚本加入定时任务
110 this.stopCronJob(script.uuid);
111 return this.crontabScript(loadScript);
112 }
113 }
114
115 async disableScript(uuid: string) {
116 // 关闭脚本

Callers

nothing calls this directly

Calls 8

disableScriptMethod · 0.95
execScriptMethod · 0.95
stopCronJobMethod · 0.95
crontabScriptMethod · 0.95
getMetadataStrFunction · 0.90
getUserConfigStrFunction · 0.90
parseUserConfigFunction · 0.90
hasMethod · 0.65

Tested by

no test coverage detected