@electron/fiddle-core

Run fiddles from anywhere, on any Electron release
CLI
$ fiddle-core run 12.0.0 /path/to/fiddle
$ fiddle-core test 12.0.0 642fa8daaebea6044c9079e3f8a46390
$ fiddle-core bisect 8.0.0 13.0.0 https://github.com/my/testcase.git
$ fiddle-core bisect 8.0.0 13.0.0 642fa8daaebea6044c9079e3f8a46390
...
🏁 finished bisecting across 438 versions...
🏁 Done bisecting
🟢 passed 12.0.1
🔴 failed 12.0.2
Commits between versions:
↔ https://github.com/electron/electron/compare/v12.0.1...v12.0.2
Done in 28.19s.
API
Hello, World!
import { Runner } from '@electron/fiddle-core';
const runner = await Runner.create();
const { status } = await runner.run('13.1.7', '/path/to/fiddle');
console.log(status);
Running Fiddles
import { Runner } from '@electron/fiddle-core';
const runner = await Runner.create();
const result = await runner.run('13.1.7', '/path/to/fiddle');
const result = await runner.run('14.0.0-beta.17', '642fa8daaebea6044c9079e3f8a46390');
const result = await runner.run('15.0.0-alpha.1', 'https://github.com/my/repo.git');
const files = new Map<string, string>([['main.js', '"use strict";']]);
const result = await runner.run('15.0.0-alpha.1', files);
const result = await runner.bisect('10.0.0', '13.1.7', path_or_gist_or_git_repo);
Managing Electron Installations
import { Installer, ProgressObject } from '@electron/fiddle-core';
const installer = new Installer();
installer.on('state-changed', ({version, state}) => {
console.log(`Version "${version}" state changed: "${state}"`);
});
await installer.ensureDownloaded('12.0.15');
const callback = (progress: ProgressObject) => {
const percent = progress.percent * 100;
console.log(`Current download progress %: ${percent.toFixed(2)}`);
};
await installer.ensureDownloaded('12.0.15', {
progressCallback: callback,
});
const npmMirrors = {
electronMirror: 'https://npmmirror.com/mirrors/electron/',
electronNightlyMirror: 'https://npmmirror.com/mirrors/electron-nightly/',
},
await installer.ensureDownloaded('12.0.15', {
mirror: npmMirrors,
});
await installer.remove('12.0.15');
const exec = await installer.install('11.4.10');
await installer.install('11.4.10', {
progressCallback: callback,
mirror: npmMirrors,
});
Versions
import { ElectronVersions } from '@electron/fiddle-core';
const elves = await ElectronVersions.create();
const { versions } = elves;
const { supportedMajors } = elves;
const { supportedMajors, prereleaseMajors } = elves;
const newestSupported = Math.max(...supportedMajors);
const oldestPrerelease = Math.min(...prereleaseMajors);
let range = releases.inRange('12.0.0', '12.0.15');
range = releases.inMajor(10);
Advanced Use
child_process.Spawn
import { Runner } from '@electron/fiddle-core';
const child = await runner.spawn('12.0.1', fiddle, nodeSpawnOpts);
Using Local Builds
import { Runner } from '@electron/fiddle-core';
const runner = await Runner.create();
const result = await runner.run('/path/to/electron/build', fiddle);
Using Custom Paths
import { Paths, Runner } from '@electron/fiddle-core';
const paths: Paths = {
electronDownloads: '/tmp/my/electron-downloads',
electronInstall: '/tmp/my/electron-install',
fiddles: '/tmp/my/fiddles',
versionsCache: '/tmp/my/releases.json',
});
const runner = await Runner.create({ paths });
Manually Creating Fiddle Objects
Runner will do this work for you; but if you want finer-grained control
over the lifecycle of your Fiddle objects, you can instantiate them yourself:
import { FiddleFactory } from '@electron/fiddle-core';
const factory = new FiddleFactory();
const fiddle = await factory.from('/path/to/fiddle'));
const fiddle = await factory.from('642fa8daaebea6044c9079e3f8a46390'));
const fiddle = await factory.from('https://github.com/my/testcase.git'));
const fiddle = await factory.from([
['main.js', '"use strict";'],
]);