Skip to content
On this page

An Issue Reproduction for Conflicts with PowerShell

This document provides steps to reproduce an issue that occurs in the following repository:

Reproduction Steps

  1. Install ni package globally.

    sh
    npm install -g @antfu/ni

    image

  2. 当我把 脚本 添加到我的 PowerShell 配置文件中,尝试修复 Conflicts with PowerShell:

    sh
    if (-not (Test-Path $profile)) {
      New-Item -ItemType File -Path (Split-Path $profile) -Force -Name (Split-Path $profile -Leaf)
    }
    
    $profileEntry = 'Remove-Item Alias:ni -Force -ErrorAction Ignore'
    $profileContent = Get-Content $profile
    if ($profileContent -notcontains $profileEntry) {
      $profileEntry | Out-File $profile -Append -Force
    }
  3. 配置在我本地的 C:\Users\admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 中时,我的 VSCode 终端却是这样的:

    image

  4. 而且之前配置的脚本多了这样的文字:

    image

  5. 但是,在当我去掉 $profileEntry 的单引号之后,就恢复了正常。

    image

Released under the MIT License.