为什么在 angular 中使用 dryRun 命令?

BMS*_*uru 9 angular

为什么使用 Angular CLI 中的 dryRun 命令?实际上,当我给 help 命令时提到了“Run through without making any changes”这句话是什么意思。

Din*_*ino 14

它完全符合你所说的。

“在不做任何更改的情况下运行”

该命令将阻止 CLI 对文件系统进行任何更改。因此,如果您不确定某个命令的作用,您可以对其进行测试,--dry-run而不必担心它会破坏您的应用程序中的某些内容。

这是如何使用它的真实示例:

ng g component test-component --dry-run

CREATE src/app/components/test-component/test-component.component.html (29 bytes)
CREATE src/app/components/test-component/test-component.component.spec.ts (678 bytes)
CREATE src/app/components/test-component/test-component.component.ts (301 bytes)
CREATE src/app/components/test-component/test-component.component.scss (0 bytes)
UPDATE src/app/app.module.ts (3181 bytes)

NOTE: The "dryRun" flag means no changes were made.
Run Code Online (Sandbox Code Playgroud)

如您所见,我运行了一个生成新组件的命令。自从我--dry-run向它添加了一个标志之后,它只给了我如果我在没有--dry-run. 我的test-component实际上并不是在我的项目中创建的。输出的最后一行几乎解释了一切:

注意:“dryRun”标志表示未进行任何更改。