Last active
August 14, 2018 20:39
-
-
Save RedTn/097fdf41505268ada6dd385e885ae7e4 to your computer and use it in GitHub Desktop.
I wanted to use the script from: https://gist.github.com/sindresorhus/7996717, but we use a windows environment at work so I wrote my own script on powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$changedFiles = git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD; | |
$hasPackageJson = $false; | |
Foreach($file in $changedFiles){ | |
if($file -like '*package.json*') { | |
$hasPackageJson = $true; | |
break; | |
} | |
} | |
if($hasPackageJson) | |
{ | |
Try { | |
iex 'yarn'; | |
} | |
Catch { | |
Write-Output 'Yarn not detected, falling back to npm'; | |
iex 'npm install'; | |
} | |
# Optional npm scripts here | |
} | |
Write-Output 'DONE'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment