-
-
Notifications
You must be signed in to change notification settings - Fork 535
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(maker): add builtin snap support
- Loading branch information
Showing
6 changed files
with
88 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import path from 'path'; | ||
|
||
import { ensureDirectory } from '../../util/ensure-output'; | ||
import configFn from '../../util/config-fn'; | ||
|
||
export const isSupportedOnCurrentPlatform = async () => process.platform === 'linux'; | ||
|
||
export default async ({ dir, targetArch, forgeConfig }) => { | ||
const installer = require('electron-installer-snap'); | ||
|
||
const outPath = path.resolve(dir, '../make'); | ||
|
||
await ensureDirectory(outPath); | ||
const snapDefaults = { | ||
arch: targetArch, | ||
dest: outPath, | ||
src: dir, | ||
}; | ||
const snapConfig = Object.assign({}, configFn(forgeConfig.electronInstallerSnap, targetArch), snapDefaults); | ||
|
||
return [await installer(snapConfig)]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import chai, { expect } from 'chai'; | ||
import chaiAsPromised from 'chai-as-promised'; | ||
import path from 'path'; | ||
import proxyquire from 'proxyquire'; | ||
import { stub } from 'sinon'; | ||
|
||
chai.use(chaiAsPromised); | ||
|
||
describe('snap maker', () => { | ||
let snapModule; | ||
let snapMaker; | ||
let eisStub; | ||
let ensureDirectoryStub; | ||
let forgeConfig; | ||
|
||
const dir = '/my/test/dir/out/foo-linux-x64'; | ||
const appName = 'My Test App'; | ||
const targetArch = process.arch; | ||
const packageJSON = { version: '1.2.3' }; | ||
|
||
beforeEach(() => { | ||
ensureDirectoryStub = stub().returns(Promise.resolve()); | ||
eisStub = stub().resolves('/my/test/dir/out/make/foo_0.0.1_amd64.snap'); | ||
forgeConfig = { electronInstallerSnap: {} }; | ||
|
||
snapModule = proxyquire.noPreserveCache().noCallThru().load('../../../src/makers/linux/snap', { | ||
'./config-fn': config => config, | ||
'../../util/ensure-output': { ensureDirectory: ensureDirectoryStub }, | ||
'electron-installer-snap': eisStub, | ||
}); | ||
snapMaker = snapModule.default; | ||
}); | ||
|
||
it('should pass through correct defaults', async () => { | ||
await snapMaker({ dir, appName, targetArch, forgeConfig, packageJSON }); | ||
const opts = eisStub.firstCall.args[0]; | ||
expect(opts).to.deep.equal({ | ||
arch: process.arch, | ||
src: dir, | ||
dest: path.resolve(dir, '..', 'make'), | ||
}); | ||
}); | ||
|
||
it('should have config cascade correctly', async () => { | ||
forgeConfig.electronInstallerSnap = { | ||
arch: 'overridden', | ||
description: 'Snap description', | ||
}; | ||
|
||
await snapMaker({ dir, appName, targetArch, forgeConfig, packageJSON }); | ||
const opts = eisStub.firstCall.args[0]; | ||
expect(opts).to.deep.equal({ | ||
arch: process.arch, | ||
src: dir, | ||
dest: path.resolve(dir, '..', 'make'), | ||
description: 'Snap description', | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters