From e5c5ca9d9ab31ef4c6a04289862d762e978c657d Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Fri, 7 Oct 2016 23:49:39 +0900 Subject: [PATCH] Use 7zip to manipulate windows zip archives --- package.json | 20 +++++++++++++++----- scripts/manipulate_windows_zip.js | 20 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 scripts/manipulate_windows_zip.js diff --git a/package.json b/package.json index 963d591e..e0f847f8 100644 --- a/package.json +++ b/package.json @@ -24,13 +24,15 @@ "watch": "gulp watch", "serve": "gulp watch", "test": "gulp build && mocha --reporter mocha-circleci-reporter --recursive test/specs && gulp prettify:verify", - "package:all": "build -wml --x64 --ia32", - "package:windows": "build --win --x64 --ia32", + "package:all": "build -wml --x64 --ia32 && npm run manipulate-windows-zip", + "package:windows": "build --win --x64 --ia32 && npm run manipulate-windows-zip", "package:mac": "build --mac --x64 --ia32", "package:linux": "build --linux --x64 --ia32", + "manipulate-windows-zip": "node scripts/manipulate_windows_zip.js", "prettify": "gulp prettify" }, "devDependencies": { + "7zip-bin": "^2.0.1", "babel-core": "^6.7.5", "babel-loader": "^6.2.4", "babel-preset-react": "^6.5.0", @@ -61,7 +63,10 @@ "appId": "com.mattermost.desktop", "linux": { "category": "InstantMessaging", - "target": ["deb", "tar.gz"], + "target": [ + "deb", + "tar.gz" + ], "synopsis": "Mattermost", "extraFiles": [{ "from": "resources", @@ -73,11 +78,16 @@ }, "mac": { "category": "public.app-category.productivity", - "target": ["tar.gz"] + "target": [ + "tar.gz" + ] }, "win": { "description": "Mattermost", - "target": ["squirrel", "zip"], + "target": [ + "squirrel", + "zip" + ], "iconUrl": "https://raw.githubusercontent.com/mattermost/desktop/master/resources/icon.ico" } }, diff --git a/scripts/manipulate_windows_zip.js b/scripts/manipulate_windows_zip.js new file mode 100644 index 00000000..019105b6 --- /dev/null +++ b/scripts/manipulate_windows_zip.js @@ -0,0 +1,20 @@ +'use strict'; + +const spawnSync = require('child_process').spawnSync; +const path7za = require('7zip-bin').path7za; +const appVersion = require('../package.json').version; + +function renameInZip(zipPath, oldName, newName) { + const result = spawnSync(path7za, ['rn', zipPath, oldName, newName]); + return result.status === 0; +} + +console.log('Manipulating 64-bit zip...'); +if (!renameInZip(`release/Mattermost-${appVersion}-win.zip`, 'win-unpacked', `Mattermost-${appVersion}-win64`)) { + throw new Error('7za returned non-zero exit code for 64-bit zip'); +} + +console.log('Manipulating 32-bit zip...'); +if (!renameInZip(`release/Mattermost-${appVersion}-ia32-win.zip`, 'win-ia32-unpacked', `Mattermost-${appVersion}-win32`)) { + throw new Error('7za returned non-zero exit code for 32-bit zip'); +}