* Run the code in VM. * * @public * @since v3.9.0 * @param {string} filename - Filename of file to load and execute in a NodeVM. * @return {*} Result of executed code. * @throws {Error} If filename is not a valid filename. * @throws {SyntaxError} If there is a syntax error in the scrip
(filename)
| 547 | * @throws {*} If the script execution terminated with an exception it is propagated. |
| 548 | */ |
| 549 | runFile(filename) { |
| 550 | const resolvedFilename = pa.resolve(filename); |
| 551 | |
| 552 | if (!fs.existsSync(resolvedFilename)) { |
| 553 | throw new VMError(`Script '${filename}' not found.`); |
| 554 | } |
| 555 | |
| 556 | if (fs.statSync(resolvedFilename).isDirectory()) { |
| 557 | throw new VMError('Script must be file, got directory.'); |
| 558 | } |
| 559 | |
| 560 | return this.run(fs.readFileSync(resolvedFilename, 'utf8'), resolvedFilename); |
| 561 | } |
| 562 | } |
| 563 | |
| 564 | exports.VM = VM; |
nothing calls this directly
no test coverage detected