@electron/get
Advanced tools
Comparing version 1.7.6 to 1.8.0
@@ -39,3 +39,3 @@ "use strict"; | ||
} | ||
const path = mirrorVar('customDir', opts, details.version); | ||
const path = mirrorVar('customDir', opts, details.version).replace('{{ version }}', details.version.replace(/^v/, '')); | ||
const file = mirrorVar('customFilename', opts, getArtifactFileName(details)); | ||
@@ -42,0 +42,0 @@ return `${base}${path}/${file}`; |
@@ -36,9 +36,19 @@ "use strict"; | ||
async function downloadArtifact(_artifactDetails) { | ||
const artifactDetails = _artifactDetails.isGeneric | ||
? Object.assign({}, _artifactDetails) : Object.assign({ platform: process.platform, arch: process.arch }, _artifactDetails); | ||
const artifactDetails = Object.assign({}, _artifactDetails); | ||
if (!_artifactDetails.isGeneric) { | ||
const platformArtifactDetails = artifactDetails; | ||
if (!platformArtifactDetails.platform) { | ||
d('No platform found, defaulting to the host platform'); | ||
platformArtifactDetails.platform = process.platform; | ||
} | ||
if (platformArtifactDetails.arch) { | ||
platformArtifactDetails.arch = utils_1.getNodeArch(platformArtifactDetails.arch); | ||
} | ||
else { | ||
d('No arch found, defaulting to the host arch'); | ||
platformArtifactDetails.arch = utils_1.getHostArch(); | ||
} | ||
} | ||
utils_1.ensureIsTruthyString(artifactDetails, 'version'); | ||
artifactDetails.version = utils_1.normalizeVersion(artifactDetails.version); | ||
if (artifactDetails.hasOwnProperty('arch')) { | ||
artifactDetails.arch = utils_1.getNodeArch(artifactDetails.arch); | ||
} | ||
const fileName = artifact_utils_1.getArtifactFileName(artifactDetails); | ||
@@ -45,0 +55,0 @@ const url = artifact_utils_1.getArtifactRemoteURL(artifactDetails); |
@@ -36,3 +36,3 @@ import { ensureIsTruthyString } from './utils'; | ||
} | ||
const path = mirrorVar('customDir', opts, details.version); | ||
const path = mirrorVar('customDir', opts, details.version).replace('{{ version }}', details.version.replace(/^v/, '')); | ||
const file = mirrorVar('customFilename', opts, getArtifactFileName(details)); | ||
@@ -39,0 +39,0 @@ return `${base}${path}/${file}`; |
@@ -8,3 +8,3 @@ import debug from 'debug'; | ||
import { initializeProxy } from './proxy'; | ||
import { withTempDirectoryIn, normalizeVersion, getNodeArch, ensureIsTruthyString, isOfficialLinuxIA32Download, } from './utils'; | ||
import { withTempDirectoryIn, normalizeVersion, getHostArch, getNodeArch, ensureIsTruthyString, isOfficialLinuxIA32Download, } from './utils'; | ||
export { getHostArch } from './utils'; | ||
@@ -32,9 +32,19 @@ export { initializeProxy } from './proxy'; | ||
export async function downloadArtifact(_artifactDetails) { | ||
const artifactDetails = _artifactDetails.isGeneric | ||
? Object.assign({}, _artifactDetails) : Object.assign({ platform: process.platform, arch: process.arch }, _artifactDetails); | ||
const artifactDetails = Object.assign({}, _artifactDetails); | ||
if (!_artifactDetails.isGeneric) { | ||
const platformArtifactDetails = artifactDetails; | ||
if (!platformArtifactDetails.platform) { | ||
d('No platform found, defaulting to the host platform'); | ||
platformArtifactDetails.platform = process.platform; | ||
} | ||
if (platformArtifactDetails.arch) { | ||
platformArtifactDetails.arch = getNodeArch(platformArtifactDetails.arch); | ||
} | ||
else { | ||
d('No arch found, defaulting to the host arch'); | ||
platformArtifactDetails.arch = getHostArch(); | ||
} | ||
} | ||
ensureIsTruthyString(artifactDetails, 'version'); | ||
artifactDetails.version = normalizeVersion(artifactDetails.version); | ||
if (artifactDetails.hasOwnProperty('arch')) { | ||
artifactDetails.arch = getNodeArch(artifactDetails.arch); | ||
} | ||
const fileName = getArtifactFileName(artifactDetails); | ||
@@ -41,0 +51,0 @@ const url = getArtifactRemoteURL(artifactDetails); |
{ | ||
"name": "@electron/get", | ||
"version": "1.7.6", | ||
"version": "1.8.0", | ||
"description": "Utility for downloading artifacts from different versions of Electron", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -75,2 +75,17 @@ # @electron/get | ||
`customDir` can have the placeholder `{{ version }}`, which will be replaced by the version | ||
specified (without the leading `v`). For example: | ||
```javascript | ||
const zipFilePath = await download('4.0.4', { | ||
mirrorOptions: { | ||
mirror: 'https://mirror.example.com/electron/', | ||
customDir: 'version-{{ version }}', | ||
platform: 'linux', | ||
arch: 'x64' | ||
} | ||
}); | ||
// Will download from https://mirror.example.com/electron/version-4.0.4/electron-v4.0.4-linux-x64.zip | ||
``` | ||
## How It Works | ||
@@ -77,0 +92,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
63668
936
113