UNPKG

lianghaijie-cli

Version:

A simple CLI for scaffolding futu5_ipo projects.

18 lines (15 loc) 495 B
const chalk = require('chalk') /** * Evaluate an expression in meta.json in the context of * prompt answers data. * 检测模板已收集的答案对象 data 中是否存在 `exp` 属性值是否存在 */ module.exports = function evaluate (exp, data) { /* eslint-disable no-new-func */ const fn = new Function('data', 'with (data) { return ' + exp + '}') try { return fn(data) } catch (e) { console.error(chalk.red('Error when evaluating filter condition: ' + exp)) } }