Skip to content

Commit a6637fb

Browse files
chore: update the npm package to use @electron/get (electron#18413)
* chore: update the npm package to use @electron/get * chore: update node requirement for got
1 parent cbc1777 commit a6637fb

File tree

2 files changed

+25
-38
lines changed

2 files changed

+25
-38
lines changed

npm/install.js

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
#!/usr/bin/env node
22

3-
var version = require('./package').version
3+
const version = require('./package').version
44

5-
var fs = require('fs')
6-
var os = require('os')
7-
var path = require('path')
8-
var extract = require('extract-zip')
9-
var download = require('electron-download')
5+
const fs = require('fs')
6+
const os = require('os')
7+
const path = require('path')
8+
const extract = require('extract-zip')
9+
const { downloadArtifact } = require('@electron/get')
1010

11-
var installedVersion = null
11+
let installedVersion = null
1212
try {
1313
installedVersion = fs.readFileSync(path.join(__dirname, 'dist', 'version'), 'utf-8').replace(/^v/, '')
1414
} catch (ignored) {
@@ -19,28 +19,26 @@ if (process.env.ELECTRON_SKIP_BINARY_DOWNLOAD) {
1919
process.exit(0)
2020
}
2121

22-
var platformPath = getPlatformPath()
22+
const platformPath = getPlatformPath()
2323

24-
var electronPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist', platformPath)
24+
const electronPath = process.env.ELECTRON_OVERRIDE_DIST_PATH || path.join(__dirname, 'dist', platformPath)
2525

2626
if (installedVersion === version && fs.existsSync(electronPath)) {
2727
process.exit(0)
2828
}
2929

3030
// downloads if not cached
31-
download({
32-
cache: process.env.electron_config_cache,
33-
version: version,
34-
platform: process.env.npm_config_platform,
35-
arch: process.env.npm_config_arch,
36-
strictSSL: process.env.npm_config_strict_ssl === 'true',
31+
downloadArtifact({
32+
version,
33+
artifactName: 'electron',
3734
force: process.env.force_no_cache === 'true',
38-
quiet: process.env.npm_config_loglevel === 'silent' || process.env.CI
39-
}, extractFile)
35+
cacheRoot: process.env.electron_config_cache,
36+
platform: process.env.npm_config_platform || process.platform,
37+
arch: process.env.npm_config_arch || process.arch
38+
}).then((zipPath) => extractFile(zipPath)).catch((err) => onerror(err))
4039

4140
// unzips and makes path.txt point at the correct executable
42-
function extractFile (err, zipPath) {
43-
if (err) return onerror(err)
41+
function extractFile (zipPath) {
4442
extract(zipPath, { dir: path.join(__dirname, 'dist') }, function (err) {
4543
if (err) return onerror(err)
4644
fs.writeFile(path.join(__dirname, 'path.txt'), platformPath, function (err) {
@@ -54,7 +52,7 @@ function onerror (err) {
5452
}
5553

5654
function getPlatformPath () {
57-
var platform = process.env.npm_config_platform || os.platform()
55+
const platform = process.env.npm_config_platform || os.platform()
5856

5957
switch (platform) {
6058
case 'darwin':

npm/package.json

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
11
{
2-
"scripts": {
3-
"cache-clean": "rm -rf ~/.electron && rm -rf dist",
4-
"postinstall": "node install.js",
5-
"pretest": "npm run cache-clean",
6-
"test": "standard"
7-
},
2+
"main": "index.js",
3+
"types": "electron.d.ts",
84
"bin": {
95
"electron": "cli.js"
106
},
11-
"main": "index.js",
12-
"types": "electron.d.ts",
7+
"scripts": {
8+
"postinstall": "node install.js"
9+
},
1310
"dependencies": {
11+
"@electron/get": "^1.0.1",
1412
"@types/node": "^10.12.18",
15-
"electron-download": "^4.1.0",
1613
"extract-zip": "^1.0.3"
1714
},
18-
"devDependencies": {
19-
"home-path": "^0.1.1",
20-
"path-exists": "^2.0.0",
21-
"standard": "^5.4.1"
22-
},
23-
"directories": {
24-
"test": "test"
25-
},
2615
"engines": {
27-
"node": ">= 4.0"
16+
"node": ">= 8.6"
2817
}
2918
}

0 commit comments

Comments
 (0)