Create DMG installers for your electron apps.
npm install electron-installer-dmg[![CI status][actions_img]][actions_url]
[![npm][npm_img]][npm_url]

> Create DMG installers for your electron apps using [appdmg][appdmg].
This module requires using macOS and Node 16 or above.
For use in npm scripts:
``bash`
npm i electron-installer-dmg --save-dev
For use from cli:
`bash`
npm i electron-installer-dmg -g
`
Usage: electron-installer-dmg
Create DMG installers for your electron apps.
Usage:
electron-installer-dmg ./FooBar-darwin-x64/FooBar.app FooBar
Options:
--out=].80
--icon=
--icon-size=].`
--background=
--title=
--overwrite Overwrite any existing DMG.
-h --help Show this screen.
--version Show version.
`javascript
const { createDMG } = require('electron-installer-dmg');
async function buildDMG() {
await createDMG({
appPath: '/path/to/app.app',
name: 'MyApp'
});
}
`
#### createDMG(opts)
##### opts
appPath - String - Required.app
The directory generated by [electron-packager][electron-packager].
name - String - Required
The application name.
title - String
The title of the produced DMG, which will be shown when mounted.
background - String
Path to the background for the DMG window. Background image should be of size 658 × 498.
icon - String
Path to the icon to use for the app in the DMG window.
iconSize - Number80
How big to make the icon for the app in the DMG. [Default: ].
overwrite - Boolean
Overwrite an existing DMG file if if already exists.
out - Stringprocess.cwd()
The directory to put the DMG into. [Default: ].
contents - Array or Function that returns an Array of objects..dmg
The content that will appear in the window when user opens the file.`
[Default: Array of two icons, application and application destination folder].
Array example:javascript`
[ { x: 448, y: 344, type: 'link', path: '/Applications'},
{ x: 192, y: 344, type: 'file', path: '/path/to/application.app'} ]`
Function example (more flexible for getting useful options used in creating a DMG):javascript`
function (opts) {
return [ { x: 448, y: 344, type: 'link', path: '/Applications'},
{ x: 192, y: 344, type: 'file', path: opts.appPath} ];
}
format - StringUDZO
Disk image format. [Default: ].
[Must be one of the following][spec]:
- UDRW :arrow_right: read/write imageUDRO
- :arrow_right: read-only imageUDCO
- :arrow_right: ADC-compressed imageUDZO
- :arrow_right: zlib-compressed imageUDBZ
- :arrow_right: bzip2-compressed imageULFO
- :arrow_right: lzfse-compressed image (macOS 10.11+ only)
additionalDMGOptions - Objectappdmg
Additional options to pass through to
You can use this to set additional features like background-color andcode-sign. See the docs of the appdmg` module for all possible options.
Apache 2.0
[actions_img]: https://github.com/electron-userland/electron-installer-dmg/actions/workflows/ci.yml/badge.svg
[actions_url]: https://github.com/electron-userland/electron-installer-dmg/actions/workflows/ci.yml
[npm_img]: https://img.shields.io/npm/v/electron-installer-dmg.svg
[npm_url]: https://npm.im/electron-installer-dmg
[electron-packager]: https://github.com/electron/electron-packager
[appdmg]: https://github.com/LinusU/node-appdmg
[spec]: https://github.com/LinusU/node-appdmg#specification