Skip to content

Instantly share code, notes, and snippets.

@RedTn
Last active August 14, 2018 20:39
Show Gist options
  • Save RedTn/097fdf41505268ada6dd385e885ae7e4 to your computer and use it in GitHub Desktop.
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
$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