All files / lib/agents xs.js

92.86% Statements 13/14
71.43% Branches 5/7
100% Functions 2/2
92.86% Lines 13/14

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35    1x 1x 1x   1x       22x   22x       22x       21x 21x 10x           11x     1x   1x  
'use strict';
 
const fs = require('fs');
const runtimePath = require('../runtime-path');
const ConsoleAgent = require('../ConsoleAgent');
 
const errorRe = /^(\w+):? ?(.*)$/m;
 
class XSAgent extends ConsoleAgent {
  async evalScript(code, options = {}) {
    this.args[0] = '-s';
 
    Iif (options.module && this.args[0] !== '-m') {
      this.args[0] = '-m';
    }
 
    return super.evalScript(code, options);
  }
 
  parseError(str) {
    let match = str.match(errorRe);
    if (match) {
      return {
        name: match[1],
        message: match[2],
        stack: [],
      };
    }
    return null;
  }
}
XSAgent.runtime = fs.readFileSync(runtimePath.for('xs'), 'utf8');
 
module.exports = XSAgent;