Skip to content

Commit

Permalink
fix: always transform arch passed to downloadArtifact (#141)
Browse files Browse the repository at this point in the history
  • Loading branch information
malept authored Feb 11, 2020
1 parent 16c4ec2 commit df791a6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
withTempDirectoryIn,
normalizeVersion,
getHostArch,
getNodeArch,
ensureIsTruthyString,
isOfficialLinuxIA32Download,
} from './utils';
Expand Down Expand Up @@ -43,7 +44,7 @@ export function download(
...options,
version,
platform: process.platform,
arch: getHostArch(),
arch: process.arch,
artifactName: 'electron',
});
}
Expand All @@ -63,11 +64,14 @@ export async function downloadArtifact(
}
: {
platform: process.platform,
arch: getHostArch(),
arch: process.arch,
..._artifactDetails,
};
ensureIsTruthyString(artifactDetails, 'version');
artifactDetails.version = normalizeVersion(artifactDetails.version);
if (artifactDetails.hasOwnProperty('arch')) {
(artifactDetails as any).arch = getNodeArch((artifactDetails as any).arch);
}

const fileName = getArtifactFileName(artifactDetails);
const url = getArtifactRemoteURL(artifactDetails);
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/SHASUMS256.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ a9709f80ad7f52db2fd8b88b97ae26d94235cf7656ed39e00630c0df91ed0d04 *electron-v2.0.
eac0266403045f0d22d4e8c864326cbf43f1cca1b6ed1ac037fcb06f6ec46522 *electron-v2.0.3-linux-x64.zip
3f1e243fce8747c125cb61ab1834b86505b0f9f476141eedd5cfb43b4b1b8c2a *electron-v2.0.3-win32-x64.zip
ff0bfe95bc2a351e09b959aab0bdab893cb33c203bfff83413c3f0989858c684 *electron-v2.0.9-darwin-x64.zip
87c5b7a966444ab1d97d7f6f5be9ffc44e2305a763bb74c1b8a940d9adbffa43 *electron-v2.0.9-linux-armv7l.zip
ec951354a58f63e5194ec47e10c493cf8d23c46c0caa9724bdba6d9a88d3695d *electron-v2.0.9-linux-x64.zip
ae7b827f0649c5ac519080ead2d507479da90f9fbf4941d696bc3e1ae984d6b3 *electron-v2.0.9-win32-x64.zip
ebb7a042d4885870cc82f510c5cb09c586ed75983a613931779bed01cfb7c657 *electron-v6.0.0-nightly.20190213-darwin-x64.zip
Expand Down
1 change: 1 addition & 0 deletions test/fixtures/electron-v2.0.9-linux-armv7l.zip
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
electron-v2.0.9-linux-armv7l.zip
14 changes: 13 additions & 1 deletion test/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,26 @@ describe('Public API', () => {
expect(await fs.readFile(dtsPath, 'utf8')).toContain('declare namespace Electron');
});

it('should work default platform/arch', async () => {
it('should work with the default platform/arch', async () => {
await downloadArtifact({
downloader,
version: '2.0.3',
artifactName: 'electron',
});
});

it('should download linux/armv7l when linux/arm is passed as platform/arch', async () => {
const zipPath = await downloadArtifact({
cacheRoot,
downloader,
artifactName: 'electron',
version: '2.0.9',
platform: 'linux',
arch: 'arm',
});
expect(path.basename(zipPath)).toMatchInlineSnapshot(`"electron-v2.0.9-linux-armv7l.zip"`);
});

it('should work for chromedriver', async () => {
const driverPath = await downloadArtifact({
cacheRoot,
Expand Down

0 comments on commit df791a6

Please sign in to comment.