0.1.1 • Published 6 years ago

mkiso v0.1.1

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

mkiso

Utility for creating ISO 9660 images

npm GitHub license Codacy Badge npm TypeScript

This library uses adapters built on burning command-line tools to generate ISO 9660 images from a source directory. In order to be able to use this module, make sure you have mkisofs installed on your linux system or hdiutil on your darwin system. It is also possible to use a custom adapter.

Installation


yarn add mkiso
npm i mkiso

Usage


The mkiso module returns a constructor that you can use to instanciate commands.

import mkiso from 'mkiso';

const cmd = mkiso(inputDirectory: string);

The following methods are available. Each of these methods can be apply before the exec() command.

label(name): set the volume name

mkiso(inputDirectory: string).label('my volume');

publisher(name): set the publisher name

mkiso(inputDirectory: string).publisher('Han Solo');

verbose(): enable the verbose mode

mkiso(inputDirectory: string).verbose();

output(target): set the iso output file path

mkiso will default to saving output image to the parent folder of input directory.

mkiso(inputDirectory: string).output('/path/to/image.iso');

adapter(adapter): Override the default adapter with a custom one

You can use an existing adapter into the adapters folder or link an external one.

mkiso(inputDirectory: string).adapter('mkisofs' | '/path/to/my/adapter');

exec(): start processing

This method must be called as a last instruction. Return a promise containing the stdout and the stderr

const res = await mkiso(inputDirectory: string)
  .label('my volume')
  .publisher('Han Solo')
  .output('/path/to/image.iso')
  .exec();

Setting event handlers

You can set event listeners for listening the process events. The following events are available:

'progress': stdout of process
'stderr': stderr of process
'error': ChildProcess.error
'close': ChildProcess.close
const res = await mkiso(inputDirectory: string)
  .output('/path/to/image.iso')
  .verbose()
  .on('error', err => console.error('Error:', err))
  .on('progress', msg => console.log('onProgress:', msg))
  .on('close', (code, signal) => console.log('onClose:', code, signal))
  .exec();