All files / builder/util run-script.ts

80% Statements 4/5
100% Branches 0/0
100% Functions 1/1
80% Lines 4/5

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  1x   1x 664x 664x          
/* eslint-disable no-console */
import vm from 'vm';
 
export function runScript(code: string, context?: vm.Context) {
  try {
    return vm.runInNewContext(code, context);
  } catch (error) {
    console.error('运行脚本错误');
  }
}