diff --git a/create-zip.bat b/create-zip.bat deleted file mode 100644 index ad0f428..0000000 --- a/create-zip.bat +++ /dev/null @@ -1,14 +0,0 @@ -echo off -set zipName=format_recit -set pluginName=recit - -rem remove the current -del %zipName% - -rem zip the folder except the folders .cache and node_modules -"c:\Program Files\7-Zip\7z.exe" a -mx "%zipName%.zip" "src\*" -mx0 -xr!"src\react_app\.cache" -xr!"src\react_app\node_modules" - -rem set the plugin name -"c:\Program Files\7-Zip\7z.exe" rn "%zipName%.zip" "src\" "%pluginName%\" - -pause \ No newline at end of file diff --git a/create-zip.ps1 b/create-zip.ps1 new file mode 100644 index 0000000..e000e04 --- /dev/null +++ b/create-zip.ps1 @@ -0,0 +1,30 @@ +function Get-PluginVersion { + $file_data = Get-Content ./src/version.php | Where-Object {$_ -like "*$plugin->release*"} + + $CharArray = $file_data.Split("=") + + $result = $CharArray[1].replace("'", "").replace(";","").trim() + + return $result +} + +function Create-Zipfile($zipName, $pluginName, $pluginVersion){ + #remove the current zip file + $zipFile="$($zipName)-$($pluginVersion).zip" + + if(Test-Path -Path $zipFile -PathType Leaf){ + Remove-Item -Path $zipFile + } + + #zip the folder except the folders .cache and node_modules + & "c:\Program Files\7-Zip\7z.exe" a -mx "$zipFile" "src\*" -mx0 -xr!"src\react_app\.cache" -xr!"src\react_app\node_modules" + + #set the plugin name + & "c:\Program Files\7-Zip\7z.exe" rn "$zipFile" "src\" "$pluginName\" +} + +$zipName="format_recit" +$pluginName="recit" +$pluginVersion = Get-PluginVersion + +Create-Zipfile $zipName $pluginName $pluginVersion \ No newline at end of file