(filename, contents)
| 303 | }, |
| 304 | |
| 305 | executeJSLibraryFile(filename, contents) { |
| 306 | const userLibraryProxy = new Proxy(this.library, { |
| 307 | set(target, prop, value) { |
| 308 | target[prop] = value; |
| 309 | if (!isDecorator(prop)) { |
| 310 | target[prop + '__user'] = true; |
| 311 | } |
| 312 | return true; |
| 313 | }, |
| 314 | }); |
| 315 | |
| 316 | const isUserLibrary = !isBeneath(filename, systemLibdir); |
| 317 | if (isUserLibrary) { |
| 318 | debugLog(`executing user JS library: ${filename}`); |
| 319 | } else { |
| 320 | debugLog(`exectuing system JS library: ${filename}`); |
| 321 | } |
| 322 | |
| 323 | let origLibrary; |
| 324 | // When we parse user libraries also set `__user` attribute |
| 325 | // on each element so that we can distinguish them later. |
| 326 | if (isUserLibrary) { |
| 327 | origLibrary = this.library; |
| 328 | this.library = userLibraryProxy; |
| 329 | } |
| 330 | pushCurrentFile(filename); |
| 331 | let preprocessedName = filename.replace(/\.\w+$/, '.preprocessed$&') |
| 332 | if (VERBOSE) { |
| 333 | preprocessedName = path.join(getTempDir(), path.basename(filename)); |
| 334 | } |
| 335 | |
| 336 | try { |
| 337 | runInMacroContext(contents, {filename: preprocessedName}) |
| 338 | } catch (e) { |
| 339 | error(`failure to execute JS library "${filename}":`); |
| 340 | if (VERBOSE) { |
| 341 | fs.writeFileSync(preprocessedName, contents); |
| 342 | error(`preprocessed JS saved to ${preprocessedName}`) |
| 343 | } else { |
| 344 | error('use -sVERBOSE to save preprocessed JS'); |
| 345 | } |
| 346 | throw e; |
| 347 | } finally { |
| 348 | popCurrentFile(); |
| 349 | if (origLibrary) { |
| 350 | this.library = origLibrary; |
| 351 | } |
| 352 | } |
| 353 | if (VERBOSE) { |
| 354 | fs.rmSync(getTempDir(), { recursive: true, force: true }); |
| 355 | } |
| 356 | } |
| 357 | }; |
| 358 | |
| 359 | // options is optional input object containing mergeInto params |
nothing calls this directly
no test coverage detected