MCPcopy Create free account
hub / github.com/MrNothing/AI-Blocks / ScriptsManager

Class ScriptsManager

Sources/src/Model/Managers/ScriptsManager.js:8–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6const isDirectory = source => lstatSync(source).isDirectory()
7
8export default class ScriptsManager{
9 constructor() {
10 this.scripts = {};
11 }
12
13 compileAllScripts()
14 {
15 try
16 {
17 let scriptFiles = this.getAllScripts("py", "", window.service.project.projectpath);
18 let scriptFiles2 = this.getAllScripts("py", "", "./scripts");
19
20 scriptFiles = scriptFiles.concat(scriptFiles2);
21
22 this.scripts = {};
23 for(let i in scriptFiles)
24 {
25 let scriptpath = scriptFiles[i];
26 let name = require('path').basename(scriptpath);
27 if(this.scripts[name]==undefined)
28 {
29 let newScript = new Script(0, name);
30 newScript.fullpath = scriptpath;
31 newScript.loadParams(scriptpath);
32 this.scripts[name] = newScript;
33 }
34 else
35 {
36 window.service.log("Error: the script: "+name+" already exists!", "Duplicates: '"+scriptpath+"' and: '"+this.scripts[name].fullpath+"'", 2);
37 }
38 }
39 }
40 catch(e)
41 {
42 alert("compileAllScripts error: "+e);
43 }
44 }
45
46 CloneScript(script)
47 {
48 let newScript = new Script(window.service.getUniqueID(), script.name);
49 newScript.fullpath = script.fullpath;
50 newScript.source = script.source;
51 newScript.params = JSON.parse(JSON.stringify(script.params));
52 return newScript;
53 }
54
55 getScriptIcon(name)
56 {
57 let script = this.scripts[name]
58 if(this.scripts[name]==undefined)
59 return null;
60 else
61 return this.scripts[name].icon;
62 }
63
64 getAllScripts(ext, folder, root)
65 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected