Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

get-powershell

cspotcode186MITdeprecated0.1.1

This package has been renamed to pwsh; all future updates and newer versions of PowerShell will appear there.

Automatically downloads and extracts PowerShell Core, allowing you to use it in NPM scripts and node projects even with Linux and Mac developers.

PowerShell, pwsh, scripts, shell, npm

readme

get-powershell

Installs powershell into an internal cache and exposes it to your npm scripts.

Alternatively, install it globally for a super-simple powershell installation.

Why?

I prefer PowerShell to bash for quickly writing npm scripts. (opinion) However, I can't expect collaborators to have it installed.* Adding "get-powershell" as a "devDependency" solves that problem without any extra effort.

* Even on Windows, "Windows PowerShell" is preinstalled but we want to use pwsh / PowerShell Core, the cross-platform, more up-to-date edition of PowerShell.

Usage

If you just want to use pwsh for your npm scripts, add us as a devDependency:

npm install --save-dev get-powershell

If you want pwsh to be globally available as an interactive shell:

npm install --global get-powershell

All installations are shared, so you can depend on "get-powershell" in many projects without downloading multiple copies of pwsh. See the FAQ for details.

Example

// Example package.json
{
    "devDependencies": {
        // Use the latest get-powershell to install pwsh 6.0.4
        "get-powershell": "pwsh6.0.4"
    },
    "scripts": {
        "test": "pwsh -NoProfile ./scripts/test.ps1"
    }
}

FAQ

Where is powershell installed?

--global installations go into your npm prefix:

  • Linux and Mac: "<npm prefix>/lib/node_modules/@cspotcode/get-powershell-cache"
  • Windows: "<npm prefix>/node_modules/@cspotcode/get-powershell-cache"

Local installations go into "$HOME/.npm-get-powershell". We use your $HOME directory because Linux and Mac, by default, require root for global installations, so the npm prefix isn't writable.

Installation is merely extracting the .zip or .tar.gz download from PowerShell Core's Github releases. No scripts are run; your system is not modified.

# To view globally installed versions on Linux and Mac
cd "$(npm get prefix)/lib/node_modules/@cspotcode/get-powershell-cache"
ls # shows all the versions installed

Installations are cached and shared, so if you work on 5 different projects that all depend on "get-powershell", only a single copy of pwsh will be downloaded. Subsequent npm installs should be very fast, merely creating a symlink at "./node_modules/.bin/pwsh".

PowerShell Core is about 50MB to download; 127MB extracted.

How do I install a specific version of pwsh?

By default we install the latest version of PowerShell Core. To install a specific version, check the dist-tags and install the one you want.

npm install get-powershell@pwsh6.0.4

*Remember, npm dist-tags !== npm versions.

changelog

v0.1.1

  • Avoid repeated, unnecessary package extractions on Windows. #11
  • Fix support for symlinked npm prefix. This affects users of nvs; possibly others. #9

v0.1.0

  • Add PowerShell Core v6.1.0.
  • Remove "beta" header from README.
  • Mark v6.0.0-rc2 as prerelease.
  • Fix nvm compatibility when running WSL tests.

v0.0.8

  • Adds support for prerelease versions of pwsh, installable via npm i get-powershell@prerelease.
  • Adds pwsh v6.1.0-rc.1.

v0.0.7

  • Adds automated tests.
  • Fix issue where npm would refuse to remove the installed symlinks / cmd shims when you npm uninstall get-powershell
  • Fix problem npm installing a fresh git clone (only affects contributors, not consumers)
  • Switch to cross-spawn; fixes bug globally installing on Windows.

v0.0.6

  • Fix broken 6.0.3 metadata.
  • Fix bug in --global installations; was not getting npm prefix correctly.

v0.0.5

  • Publishes tagged packages that install a specific version of PowerShell Core rather than the latest version.
  • Bundles via webpack to eliminate all npm dependencies and install faster.
  • --global installs cache in npm prefix; local installations still cache in $HOME

v0.0.4

  • I did not keep a changelog for this version and prior.