MCPcopy Create free account
hub / github.com/CloudOrc/SolidUI / constructor

Method constructor

solidui-web/scripts/utils.js:40–61  ·  view source on GitHub ↗
(config, callback = () => { })

Source from the content-addressed store, hash-verified

38 options = [];
39
40 constructor(config, callback = () => { }) {
41 this.config = config;
42 const line = [...process.argv]
43 this.nodePath = line.shift()
44 this.scriptPath = line.shift()
45 // 命令
46 const findCommand = line.find(item => /^[a-zA-Z0-9]+$/g.test(item))
47 // 选项
48 const findOptions = line.map(item => {
49 const regExpExecArray = /^--([a-zA-Z0-9]+)$/g.exec(item);
50 return regExpExecArray && regExpExecArray[1]
51 }).filter(Boolean)
52 if (findCommand === void 0) exitProcess("Specify the command to execute")
53
54 const hitCommand = config.commandls.find(item => item.command === findCommand)
55 if (!hitCommand) exitProcess(findCommand + " Command not defined")
56
57 const hitOptions = findOptions.filter((option) => hitCommand.options.includes(option))
58 this.command = hitCommand
59 this.options = hitOptions
60 callback(hitCommand, hitOptions, this)
61 }
62 hasOption(option) {
63 return this.options.includes(option)
64 }

Callers

nothing calls this directly

Calls 1

exitProcessFunction · 0.85

Tested by

no test coverage detected