Skip to content

Commit 37a0f2c

Browse files
authored
Merge pull request #1139 - refactor: replace cross-zip with extract-zip
2 parents 39851a1 + bc61ca5 commit 37a0f2c

File tree

5 files changed

+22
-28
lines changed

5 files changed

+22
-28
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ It generates executables/bundles for the following **target** platforms:
5252

5353
## Installation
5454

55-
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).
55+
This module requires Node.js 10.0 or higher to run.
5656

5757
```sh
5858
# For use in npm scripts (recommended)

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"dependencies": {
3030
"@electron/get": "^1.6.0",
3131
"asar": "^3.0.0",
32-
"cross-zip": "^3.0.0",
3332
"debug": "^4.0.1",
3433
"electron-notarize": "^0.2.0",
3534
"electron-osx-sign": "^0.4.11",
35+
"extract-zip": "^2.0.0",
3636
"fs-extra": "^9.0.0",
3737
"galactus": "^0.2.1",
3838
"get-package-info": "^1.0.0",

src/unzip.js

+2-26
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,7 @@
11
'use strict'
22

3-
const os = require('os')
4-
const { promisify } = require('util')
5-
const { warning } = require('./common')
6-
const zip = require('cross-zip')
7-
8-
const unzip = promisify(zip.unzip)
9-
10-
/**
11-
* Detects Windows 7 via release number.
12-
*
13-
* 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.
14-
*/
15-
function probablyWindows7 () {
16-
if (process.platform === 'win32') {
17-
const [majorVersion, minorVersion] = os.release().split('.').map(Number)
18-
return majorVersion === 6 && minorVersion === 1
19-
}
20-
21-
return false
22-
}
3+
const extractZip = require('extract-zip')
234

245
module.exports = async function extractElectronZip (zipPath, targetDir) {
25-
if (probablyWindows7()) {
26-
/* istanbul ignore next */
27-
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.')
28-
}
29-
30-
return unzip(zipPath, targetDir)
6+
await extractZip(zipPath, { dir: targetDir })
317
}

test/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require('./infer')
1010
require('./hooks')
1111
require('./prune')
1212
require('./targets')
13+
require('./unzip')
1314
require('./win32')
1415

1516
if (process.platform !== 'win32') {

test/unzip.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict'
2+
3+
const { assertSymlink } = require('./_util')
4+
const config = require('./config.json')
5+
const download = require('../src/download')
6+
const path = require('path')
7+
const test = require('ava')
8+
const unzip = require('../src/unzip')
9+
10+
test('unzip preserves symbolic links', async t => {
11+
const downloadOpts = download.createDownloadOpts({ electronVersion: config.version }, 'darwin', 'x64')
12+
const zipPath = await download.downloadElectronZip(downloadOpts)
13+
14+
await unzip(zipPath, t.context.tempDir)
15+
16+
await assertSymlink(t, path.join(t.context.tempDir, 'Electron.app/Contents/Frameworks/Electron Framework.framework/Libraries'), 'symbolic link extracted correctly')
17+
})

0 commit comments

Comments
 (0)