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

Function createFile

Sources/src/Model/UI/CreateScript.js:20–52  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18 }
19
20 createFile()
21 {
22 if(this.state.scriptname.length==0)
23 {
24 alert("Please specify a script name!");
25 }
26 else if(this.state.already_exists)
27 {
28 alert("A script with this name already exists!");
29 }
30 else{
31 let path = this.state.scriptpath+"/"+this.state.scriptname+".py";
32
33 let content = fs.readFileSync("./templates/"+this.state.template);
34
35 fs.writeFile(path, content, (err) => {
36 if(err){
37 alert(err);
38 LogErr("An error ocurred while creating the file "+ err.message);
39 }
40 else{
41 window.service.scriptsManager.compileAllScripts();
42 window.service.scriptsManager.updateAllProjectScriptInstances();
43 if(window.service.createScriptcallback)
44 {
45 window.service.createScriptcallback(this.state.scriptname+".py");
46 }
47
48 $('#script-creator').modal("hide");
49 }
50 });
51 }
52 }
53
54 selectScriptFolder()
55 {

Callers

nothing calls this directly

Calls 3

LogErrFunction · 0.85
compileAllScriptsMethod · 0.80

Tested by

no test coverage detected