Created
December 30, 2015 08:07
-
-
Save saschanaz/270e0f7d89dfba858fb9 to your computer and use it in GitHub Desktop.
TypeScript Sync
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
| Set-StrictMode -Version Latest | |
| $CurrentTime = get-date -format yyyy-MM-dd-HH-mm-ss | |
| Function Test-Admin { [bool]((whoami /groups) -Match "S-1-16-12288") } | |
| Function Backup-Item($filename) { | |
| if (Test-Path $filename) { | |
| Rename-Item $filename $(Get-Backupname $filename $CurrentTime) | |
| } | |
| } | |
| Function Get-Backupname($filename, $time) { | |
| $index = $filename.IndexOf(".") | |
| $pre = $filename.Substring(0, $index) | |
| $post = $filename.Substring($index) | |
| Return "$pre.bak-$time$post"; | |
| } | |
| If (!(Test-Admin)) { | |
| Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList "-noexit -file $($myinvocation.Mycommand.path)" | |
| exit | |
| } | |
| cd $psscriptroot | |
| # Versions | |
| $TSToolVersion = "1.7" | |
| $VSVersion = "14.0" | |
| # Pathes | |
| $CompilerPath = "${Env:ProgramFiles(x86)}\Microsoft SDKs\TypeScript\$TSToolVersion" | |
| $LanguageServicePath = "${Env:ProgramFiles(x86)}\Microsoft Visual Studio $VSVersion\Common7\IDE\CommonExtensions\Microsoft\TypeScript" | |
| $LocalRepoPath = "typescript-f" | |
| # Compile | |
| Push-Location $LocalRepoPath | |
| jake | |
| Pop-Location | |
| # Backup | |
| Push-Location $CompilerPath | |
| Backup-Item tsc.js | |
| Backup-Item lib.d.ts | |
| Backup-Item lib.es6.d.ts | |
| Pop-Location | |
| Push-Location $LanguageServicePath | |
| Backup-Item typescriptServices.js | |
| Backup-Item lib.d.ts | |
| Backup-Item lib.es6.d.ts | |
| Pop-Location | |
| # Copy | |
| Push-Location $LocalRepoPath\built\local | |
| Copy-Item tsc.js $CompilerPath | |
| Copy-Item typescriptServices.js $LanguageServicePath | |
| #Pop-Location | |
| #Push-Location $LocalRepoPath\bin | |
| Copy-Item lib.d.ts $CompilerPath\lib.d.ts | |
| Copy-Item lib.es6.d.ts $CompilerPath\lib.es6.d.ts | |
| Copy-Item lib.d.ts $LanguageServicePath\lib.d.ts | |
| Copy-Item lib.es6.d.ts $LanguageServicePath\lib.es6.d.ts | |
| Pop-Location |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment