@electron-forge/test-utils 6.0.0-beta.69 → 6.0.0-beta.70
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.
- package/index.ts +3 -0
- package/package.json +2 -2
- package/src/index.ts +49 -0
package/index.ts
ADDED
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@electron-forge/test-utils",
|
|
3
|
-
"version": "6.0.0-beta.
|
|
3
|
+
"version": "6.0.0-beta.70",
|
|
4
4
|
"description": "Helper utilities for the Electron Forge testsuite",
|
|
5
|
-
"repository": "https://github.com/electron
|
|
5
|
+
"repository": "https://github.com/electron/forge",
|
|
6
6
|
"author": "Mark Lee",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index.js",
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import { ExitError, spawn } from '@malept/cross-spawn-promise';
|
|
5
|
+
import { expect } from 'chai';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
|
|
8
|
+
async function runNPM(dir: string, ...args: string[]) {
|
|
9
|
+
await spawn('npm', args, { cwd: dir });
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
async function runNPMInstall(dir: string, ...args: string[]) {
|
|
13
|
+
await runNPM(dir, 'install', ...args);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export async function ensureModulesInstalled(dir: string, deps: string[], devDeps: string[]): Promise<void> {
|
|
17
|
+
await runNPMInstall(dir, ...deps);
|
|
18
|
+
await runNPMInstall(dir, '--save-dev', ...devDeps);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
let dirID = Date.now();
|
|
22
|
+
|
|
23
|
+
export async function ensureTestDirIsNonexistent(): Promise<string> {
|
|
24
|
+
const dir = path.resolve(os.tmpdir(), `electron-forge-test-${dirID}`);
|
|
25
|
+
dirID += 1;
|
|
26
|
+
await fs.remove(dir);
|
|
27
|
+
|
|
28
|
+
return dir;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function expectLintToPass(dir: string): Promise<void> {
|
|
32
|
+
try {
|
|
33
|
+
await runNPM(dir, 'run', 'lint');
|
|
34
|
+
} catch (err) {
|
|
35
|
+
if (err instanceof ExitError) {
|
|
36
|
+
console.error('STDOUT:', err.stdout.toString());
|
|
37
|
+
console.error('STDERR:', err.stderr.toString());
|
|
38
|
+
}
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function expectProjectPathExists(dir: string, subPath: string, pathType: string, exists = true): Promise<void> {
|
|
44
|
+
expect(await fs.pathExists(path.resolve(dir, subPath)), `the ${subPath} ${pathType} should exist`).to.equal(exists);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export async function expectProjectPathNotExists(dir: string, subPath: string, pathType: string): Promise<void> {
|
|
48
|
+
await expectProjectPathExists(dir, subPath, pathType, false);
|
|
49
|
+
}
|