Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace cross-zip with extract-zip #1139

Merged
merged 3 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ It generates executables/bundles for the following **target** platforms:

## Installation

This module requires Node.js 10.0 or higher to run. On macOS/Linux, the `unzip` program is required. On Windows, both [.NET Framework 4.5 or higher and Powershell 3 or higher are required](https://github.com/feross/cross-zip#windows-users).
This module requires Node.js 10.0 or higher to run.

```sh
# For use in npm scripts (recommended)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
"dependencies": {
"@electron/get": "^1.6.0",
"asar": "^3.0.0",
"cross-zip": "^3.0.0",
"debug": "^4.0.1",
"electron-notarize": "^0.2.0",
"electron-osx-sign": "^0.4.11",
"extract-zip": "^2.0.0",
"fs-extra": "^9.0.0",
"galactus": "^0.2.1",
"get-package-info": "^1.0.0",
Expand Down
28 changes: 2 additions & 26 deletions src/unzip.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
'use strict'

const os = require('os')
const { promisify } = require('util')
const { warning } = require('./common')
const zip = require('cross-zip')

const unzip = promisify(zip.unzip)

/**
* Detects Windows 7 via release number.
*
* This also detects Windows Server 2008 R2, but since we're using it to determine whether to check * for Powershell/.NET Framework, it's fine.
*/
function probablyWindows7 () {
if (process.platform === 'win32') {
const [majorVersion, minorVersion] = os.release().split('.').map(Number)
return majorVersion === 6 && minorVersion === 1
}

return false
}
const extractZip = require('extract-zip')

module.exports = async function extractElectronZip (zipPath, targetDir) {
if (probablyWindows7()) {
/* istanbul ignore next */
warning('Make sure that .NET Framework 4.5 or later and Powershell 3 or later are installed, otherwise extracting the Electron zip file will hang.')
}

return unzip(zipPath, targetDir)
await extractZip(zipPath, { dir: targetDir })
}
1 change: 1 addition & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require('./infer')
require('./hooks')
require('./prune')
require('./targets')
require('./unzip')
require('./win32')

if (process.platform !== 'win32') {
Expand Down
17 changes: 17 additions & 0 deletions test/unzip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

const { assertSymlink } = require('./_util')
const config = require('./config.json')
const download = require('../src/download')
const path = require('path')
const test = require('ava')
const unzip = require('../src/unzip')

test('unzip preserves symbolic links', async t => {
const downloadOpts = download.createDownloadOpts({ electronVersion: config.version }, 'darwin', 'x64')
const zipPath = await download.downloadElectronZip(downloadOpts)

await unzip(zipPath, t.context.tempDir)

await assertSymlink(t, path.join(t.context.tempDir, 'Electron.app/Contents/Frameworks/Electron Framework.framework/Libraries'), 'symbolic link extracted correctly')
})