编写自己的Yeoman生成器-9.调试生成器

要调试生成器,可以通过运行它来传递Node.js调试标志,如下所示:

1
2
3
4
5
6
7
8
9
10
11
12
# OS X / Linux
node --inspect `which yo` <generator> [arguments]

# Windows
# Find the path to the yo binary in Command Prompt
where yo
# Or find the path to the yo binary in PowerShell
get-command yo
# Would be something like C:\Users\<USER>\AppData\Roaming\npm\yo
# Use this path to derive yo cli.js file
# C:\Users\<USER>\AppData\Roaming\npm\node_modules\yo\lib\cli.js
node --inspect <path to yo cli.js> <generator> [arguments]

然后,您可以使用Chrome Devtools或首选IDE调试您的生成器。有关详细信息,请参阅Node调试指南

Yeoman生成器还提供调试模式来记录相关的生命周期信息。您可以通过将DEBUG环境变量设置为所需范围(生成器系统的范围yeoman:generator)来激活它。

1
2
3
4
5
# OS X / Linux
DEBUG=yeoman:generator

# Windows
set DEBUG=yeoman:generator

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2021 朝着牛逼的道路一路狂奔 All Rights Reserved.

访客数 : | 访问量 :