Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Binary file added spec/fixtures/app/vk_swiftshader.dll
Binary file not shown.
1 change: 1 addition & 0 deletions spec/fixtures/app/vk_swiftshader_icd.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"file_format_version": "1.0.0", "ICD": {"library_path": ".\\vk_swiftshader.dll", "api_version": "1.0.5"}}
20 changes: 19 additions & 1 deletion spec/installer-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import path from 'path';
import { createTempDir } from '../src/temp-utils';
import fs from 'fs-extra';
import { createWindowsInstaller } from '../src';
import spawn from '../src/spawn-promise';

const log = require('debug')('electron-windows-installer:spec');

Expand All @@ -29,7 +30,9 @@ test('creates a nuget package and installer', async (t): Promise<void> => {
log(`Verifying assertions on ${outputDirectory}`);
log(JSON.stringify(await fs.readdir(outputDirectory)));

t.true(await fs.pathExists(path.join(outputDirectory, 'myapp-1.0.0-full.nupkg')));
const nupkgPath = path.join(outputDirectory, 'myapp-1.0.0-full.nupkg');

t.true(await fs.pathExists(nupkgPath));
t.true(await fs.pathExists(path.join(outputDirectory, 'MyAppSetup.exe')));

if (process.platform === 'win32') {
Expand All @@ -38,4 +41,19 @@ test('creates a nuget package and installer', async (t): Promise<void> => {

log('Verifying Update.exe');
t.true(await fs.pathExists(path.join(appDirectory, 'Squirrel.exe')));

log('Verifying contents of .nupkg');
const sevenZipPath = path.join(__dirname, '..', 'vendor', '7z.exe');
let cmd = sevenZipPath;
const args = ['l', nupkgPath];

if (process.platform !== 'win32') {
args.unshift(cmd);
const wineExe = process.arch === 'x64' ? 'wine64' : 'wine';
cmd = wineExe;
}

const packageContents = await spawn(cmd, args);
t.true(packageContents.includes('lib\\net45\\vk_swiftshader_icd.json'));
t.true(packageContents.includes('lib\\net45\\swiftshader\\libEGL.dll'));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if there was a test that didn't add the swiftshader files as well, to prevent regressions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, I'll take a stab at it!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I encountered an issue where the two tests caused a race condition trying to delete the Squirrel.exe file in the beforeEach so I tweaked the approach to always copying the fixture app directory to a temporary location before packaging.

});
13 changes: 13 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,23 @@ export async function createWindowsInstaller(options: Options): Promise<void> {
metadata.version = convertVersion(metadata.version as string);
metadata.copyright = metadata.copyright ||
`Copyright © ${new Date().getFullYear()} ${metadata.authors || metadata.owners}`;
metadata.additionalFiles = metadata.additionalFiles || [];

if (await fs.pathExists(path.join(appDirectory, 'swiftshader'))) {
metadata.additionalFiles.push({ src: 'swiftshader\\**', target: 'lib\\net45\\swiftshader' });
}

if (await fs.pathExists(path.join(appDirectory, 'vk_swiftshader_icd.json'))) {
metadata.additionalFiles.push({ src: 'vk_swiftshader_icd.json', target: 'lib\\net45' });
}

let templateData = await fs.readFile(path.join(__dirname, '..', 'template.nuspectemplate'), 'utf8');
if (path.sep === '/') {
templateData = templateData.replace(/\\/g, '/');
for (const f of metadata.additionalFiles) {
f.src = f.src.replace(/\\/g, '/');
f.target = f.target.replace(/\\/g, '/');
}
}
const nuspecContent = template(templateData)(metadata);

Expand Down
6 changes: 6 additions & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ export interface PersonMetadata {
url?: string;
}

export interface AdditionalFile {
src: string;
target: string;
}

export interface Metadata {
name?: string;
productName?: string;
Expand All @@ -143,4 +148,5 @@ export interface Metadata {
owners?: string | PersonMetadata[];
description?: string;
iconUrl?: string;
additionalFiles?: AdditionalFile[];
}
3 changes: 3 additions & 0 deletions template.nuspectemplate
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,8 @@
<file src="Squirrel.exe" target="lib\net45\squirrel.exe" />
<file src="LICENSE" target="lib\net45\LICENSE" />
<file src="<%- exe %>" target="lib\net45\<%- exe %>" />
<% additionalFiles.forEach(function(f) { %>
<file src="<%- f.src %>" target="<%- f.target %>" />
<% }); %>
</files>
</package>