| 4 | const isDirectory = source => lstatSync(source).isDirectory() |
| 5 | |
| 6 | export default class Script{ |
| 7 | constructor(id, source) { |
| 8 | this.id = id; |
| 9 | window.service.checkMaxID(this.id); |
| 10 | this.description = ""; |
| 11 | this.source = source; |
| 12 | this.fullpath = null; |
| 13 | this.params = []; |
| 14 | this.paramsIndex = {}; |
| 15 | this.icon = null; |
| 16 | } |
| 17 | |
| 18 | getFile() |
| 19 | { |
| 20 | let filepath = this.findFileInFolder(this.source, ""); |
| 21 | |
| 22 | if(filepath=="") |
| 23 | { |
| 24 | window.service.log("Could not find the Script: "+this.source, "", 2); |
| 25 | return ""; |
| 26 | } |
| 27 | else |
| 28 | { |
| 29 | filepath = require('path').resolve(window.service.project.projectpath+filepath); |
| 30 | |
| 31 | return filepath; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | loadParams(filepath) |
| 36 | { |
| 37 | let context = this; |
| 38 | |
| 39 | let data = fs.readFileSync(filepath); |
| 40 | |
| 41 | let array = data.toString().split("\n"); |
| 42 | |
| 43 | let next_is_param = false; |
| 44 | let type = 'string'; |
| 45 | let condition = ""; |
| 46 | |
| 47 | for(let i in array) { |
| 48 | |
| 49 | let line = array[i]; |
| 50 | |
| 51 | if(line.indexOf("#description")==0) |
| 52 | { |
| 53 | this.description += line.substring(13, line.length)+"\n"; |
| 54 | } |
| 55 | |
| 56 | if(line.indexOf("#icon")==0) |
| 57 | { |
| 58 | this.icon = line.substring(6, line.length).trim(); |
| 59 | } |
| 60 | |
| 61 | if(line.indexOf("#zone")==0) |
| 62 | condition = line.replace("#zone", "").trim() |
| 63 |
nothing calls this directly
no outgoing calls
no test coverage detected