@electron-forge/plugin-local-electron 6.0.0-beta.6 → 6.0.0-beta.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,116 +0,0 @@
1
- import { expect } from 'chai';
2
- import fs from 'fs-extra';
3
- import os from 'os';
4
- import path from 'path';
5
-
6
- import LocalElectronPlugin from '../src/LocalElectronPlugin';
7
-
8
- describe('LocalElectronPlugin', () => {
9
- describe('start logic', () => {
10
- before(() => {
11
- delete process.env.ELECTRON_OVERRIDE_DIST_PATH;
12
- });
13
-
14
- afterEach(() => {
15
- delete process.env.ELECTRON_OVERRIDE_DIST_PATH;
16
- });
17
-
18
- it('should set ELECTRON_OVERRIDE_DIST_PATH when enabled', async () => {
19
- expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined);
20
- const p = new LocalElectronPlugin({ electronPath: 'test/foo' });
21
- await p.startLogic();
22
- expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal('test/foo');
23
- });
24
-
25
- it('should not set ELECTRON_OVERRIDE_DIST_PATH when disabled', async () => {
26
- expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined);
27
- const p = new LocalElectronPlugin({ enabled: false, electronPath: 'test/foo' });
28
- await p.startLogic();
29
- expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined);
30
- });
31
-
32
- it('should throw an error if platforms don\'t match', async () => {
33
- const p = new LocalElectronPlugin({ electronPath: 'test/bar', electronPlatform: 'wut' });
34
- await expect(p.startLogic()).to.eventually.be.rejectedWith(
35
- `Can not use local Electron version, required platform "${process.platform}" but local platform is "wut"`,
36
- );
37
- });
38
-
39
- it('should always return false', async () => {
40
- let p = new LocalElectronPlugin({ electronPath: 'test/bar' });
41
- expect(await p.startLogic()).to.equal(false);
42
-
43
- p = new LocalElectronPlugin({ enabled: false, electronPath: 'test/bar' });
44
- expect(await p.startLogic()).to.equal(false);
45
- });
46
- });
47
-
48
- describe('hooks', () => {
49
- let p: LocalElectronPlugin;
50
-
51
- beforeEach(() => {
52
- p = new LocalElectronPlugin({ electronPath: 'test/foo' });
53
- });
54
-
55
- it('should return for all other hooks', () => {
56
- expect(p.getHook('prePackage')).to.equal(null);
57
- expect(p.getHook('postMake')).to.equal(null);
58
- });
59
-
60
- describe('with afterExtract hook', () => {
61
- let tmpDir: string;
62
-
63
- beforeEach(async () => {
64
- tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'forge-test-'));
65
- await fs.writeFile(path.resolve(tmpDir, 'touch'), 'hey');
66
- });
67
-
68
- afterEach(() => {
69
- return fs.remove(tmpDir);
70
- });
71
-
72
- it('should return a function for packageAfterExtract', () => {
73
- expect(p.getHook('packageAfterExtract')).to.be.a('function');
74
- });
75
-
76
- it('should do nothing when disabled', async () => {
77
- p.config.enabled = false;
78
- const fn = p.getHook('packageAfterExtract')!;
79
-
80
- await fn(null, tmpDir, null, process.platform, process.arch);
81
-
82
- expect(await fs.pathExists(tmpDir)).to.equal(true);
83
- expect(await fs.pathExists(path.resolve(tmpDir, 'touch'))).to.equal(true);
84
- });
85
-
86
- it('should throw an error if the platform doesn\'t match', async () => {
87
- const fn = p.getHook('packageAfterExtract')!;
88
-
89
- await expect(fn(null, tmpDir, null, 'bad', process.arch)).to.eventually.be.rejectedWith(
90
- `Can not use local Electron version, required platform "bad" but local platform is "${process.platform}"`,
91
- );
92
- });
93
-
94
- it('should throw an error if the arch doesn\'t match', async () => {
95
- const fn = p.getHook('packageAfterExtract')!;
96
-
97
- await expect(fn(null, tmpDir, null, process.platform, 'bad')).to.eventually.be.rejectedWith(
98
- `Can not use local Electron version, required arch "bad" but local arch is "${process.arch}"`,
99
- );
100
- });
101
-
102
- it('should copy the electron dir to the build dir if everything is ok and enabled', async () => {
103
- const electronDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-tmp-'));
104
- await fs.writeFile(path.resolve(electronDir, 'electron'), 'hi i am electron I swear');
105
- p.config.electronPath = electronDir;
106
- const fn = p.getHook('packageAfterExtract')!;
107
-
108
- await fn(null, tmpDir, null, process.platform, process.arch);
109
-
110
- expect(await fs.pathExists(path.resolve(tmpDir, 'touch'))).to.equal(false);
111
- expect(await fs.pathExists(path.resolve(tmpDir, 'electron'))).to.equal(true);
112
- expect(await fs.readFile(path.resolve(tmpDir, 'electron'), 'utf8')).to.equal('hi i am electron I swear');
113
- });
114
- });
115
- });
116
- });
package/tslint.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "extends": "tslint-config-airbnb",
3
- "rules": {
4
- "no-boolean-literal-compare": false,
5
- "import-name": false,
6
- "align": false,
7
- "variable-name": [true, "ban-keywords", "check-format", "allow-pascal-case"],
8
- "no-this-assignment": [true, { "allow-destructuring": true }],
9
- "max-line-length": false,
10
- "no-parameter-reassignment": false
11
- }
12
- }