Verified Commit 768c13c2 authored by Camil Staps's avatar Camil Staps 🚀

Add wrapper around electron-packager

parent c9fd4d85
......@@ -110,14 +110,34 @@ To distribute your application you don't want your users to have to install
Node.js. It is possible to package Electron applications complete with a Chrome
runtime, so that you get a completely stand-alone application.
To do this with an iTasks-Electron application, you need to write a `build.js`
script that collects all relevant files and uses
[`electron-packager`][electron-packager] to create a stand-alone distribution.
I am still in the process of creating helper functions to easily write a
`build.js`. For now, you can see how it is done in TextSheets:
You need to run `npm install --save-dev electron-packager copy-dir` to install
the necessary dependencies to be able to package applications.
After that, you need to write a `build.js` using iTask-Electron's
`clean-electron-packager.js`. A simple `build.js` looks like this:
const path=require ('path');
const packager=require ('./iTasks-electron/src/clean-electron-packager.js');
packager ({
out: path.join ('..','dist'),
cleanApp: 'myproject',
electronApp: 'ApplicationName'
}).then (appPaths => {
console.log (`Electron app bundles created:\n${appPaths.join('\n')}`);
This assumes that the Clean application (excluding `.exe`) is called
`myproject`. The application is put in `../dist/<name>-<platform>-<arch>`, and
the main executable is `ApplicationName` (with the appropriate extension
depending on the operating system).
In more advanced cases you may want to ignore certain files from the
distribution, or add files in the build step. See the build script of
TextSheets for a more advanced configuration:
const fs=require ('fs');
const path=require ('path');
const copydir=require ('copy-dir');
const packager=require ('electron-packager');
module.exports=function (_opts) {
const opts={
dir: '.',
out: _opts.out,
overwrite: true,
executableName: _opts.electronApp,
ignore: [
/^\/Clean System Files$/,
afterCopy: [
(buildPath,version,platform,arch,done) => {
/* -www directory is expected at the root */
copydir.sync (
path.join (buildPath,_opts.cleanApp+'-www'),
path.join (buildPath,'..','..',_opts.cleanApp+'-www')
/* Server app is expected at the root */
const exts=['exe','bc','pbc'];
for (i in exts)
fs.renameSync (
path.join (buildPath,_opts.cleanApp+'.'+exts[i]),
path.join (buildPath,'..','..',_opts.cleanApp+'.'+exts[i])
if ('afterCopy' in _opts)
_opts.afterCopy (buildPath,version,platform,arch,done);
if ('ignore' in _opts)
opts.ignore.concat (_opts.ignore);
return packager (opts);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment