MCPcopy
hub / github.com/chavyleung/scripts / runScript

Method runScript

Env.js:149–176  ·  view source on GitHub ↗
(script, runOpts)

Source from the content-addressed store, hash-verified

147 }
148
149 runScript(script, runOpts) {
150 return new Promise((resolve) => {
151 let httpapi = this.getdata('@chavy_boxjs_userCfgs.httpapi')
152 httpapi = httpapi ? httpapi.replace(/\n/g, '').trim() : httpapi
153 let httpapi_timeout = this.getdata(
154 '@chavy_boxjs_userCfgs.httpapi_timeout'
155 )
156 httpapi_timeout = httpapi_timeout ? httpapi_timeout * 1 : 20
157 httpapi_timeout =
158 runOpts && runOpts.timeout ? runOpts.timeout : httpapi_timeout
159 const [key, addr] = httpapi.split('@')
160 const opts = {
161 url: `http://${addr}/v1/scripting/evaluate`,
162 body: {
163 script_text: script,
164 mock_type: 'cron',
165 timeout: httpapi_timeout
166 },
167 headers: {
168 'X-Key': key,
169 'Accept': '*/*'
170 },
171 policy: 'DIRECT',
172 timeout: httpapi_timeout
173 }
174 this.post(opts, (err, resp, body) => resolve(body))
175 }).catch((e) => this.logErr(e))
176 }
177
178 loaddata() {
179 if (this.isNode()) {

Callers

nothing calls this directly

Calls 3

getdataMethod · 0.45
postMethod · 0.45
logErrMethod · 0.45

Tested by

no test coverage detected