You can integrate appdmg into your JavaScript applications. The API accepts either a source file path or a specification object directly.
If using a specification object, provide a basepath to resolve relative paths.
The function returns an EventEmitter that emits several events:
progress: Emits { current, total, type, title, status }. type is step-begin or step-end. status is ok, skip, or fail.finish: Emitted when the DMG is successfully created.error: Emitted when an error occurs.
const appdmg = require('appdmg');
// Using a source file
const ee = appdmg({ source: 'test/appdmg.json', target: 'test.dmg' });
// OR using a specification object directly
const ee = appdmg({
target: 'test.dmg',
basepath: __dirname,
specification: {
"title": "Test Title"
}
});
ee.on('progress', function (info) {
// info.current, info.total, info.type, info.title, info.status
});
ee.on('finish', function () {
// DMG is ready
});
ee.on('error', function (err) {
// Handle error
});