PowerShell脚本
脚本中使用到了 yarn 工具,需要提前在系统中安装。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $baseDir="D:\Git\workspace\mywebsite\Web" & cd $baseDir & yarn build $sourceFolder=Join-Path -Path $baseDir -ChildPath "dist" $webSiteFolder="D:\WebSite\mywebsite" $webSiteFolder $destFolder=Join-Path -Path $webSiteFolder -ChildPath "web" $destFolder $backFolder=Join-Path -Path $webSiteFolder -ChildPath "web_back" $backFolder $now=Get-Date -Format "yyyy-MM-dd_HHmmss" $backFileName=-join ($now,".zip") $fullFolder=Join-Path -Path $backFolder -ChildPath $backFileName Compress-Archive -Path $destFolder -DestinationPath $fullFolder -Force $removeFolder=-join($destFolder,"\*") Remove-Item $removeFolder -Recurse -Force $fullSourceFolder=-join ($sourceFolder,"\*") Copy-Item -Path $fullSourceFolder -Destination $destFolder -Recurse
|
参考:
使用PowerShell压缩和解压ZIP包