适用于 Windows 和非 Windows 系统的终端使用规则,并包含 Windows PowerShell 的专项注意事项。只要需要使用终端就应加载,尤其是在 Windows 或 PowerShell 环境中。
只要在终端中执行操作,都应遵守以下规则。
$env:NO_COLOR="1"$env:CLICOLOR="0"$env:CLICOLOR_FORCE="0"--color=never--no-color在 Windows,尤其是 PowerShell 环境下,还应额外遵守以下规则。
&& 在不同 PowerShell 版本中的一致行为。;cd my-dir && npm install && npm run buildcd my-dir ; npm install ; npm run buildNODE_ENV=production npm run build$env:NODE_ENV="production"; npm run build/dev/null。$null 代替。command > /dev/null 2>&1command > $null 2>&1command *>$nullgrep、sed、awk 这类 Linux 工具存在且行为一致。ls、cat、rm 等命令在 PowerShell 中可能只是 Get-ChildItem、Get-Content、Remove-Item 的别名,其参数和 GNU 工具差异很大。rm -rf my-folderRemove-Item -Recurse -Force my-foldersudo。`。utf-8,避免因为 PowerShell 默认编码不一致而出现乱码或内容损坏。Get-Content、Set-Content、Add-Content、Out-File 等命令时,合适的情况下显式指定 -Encoding utf8。