diff --git a/dist/index.cjs b/dist/index.cjs new file mode 100644 index 0000000..aef311e --- /dev/null +++ b/dist/index.cjs @@ -0,0 +1,674 @@ +'use strict'; + +Object.defineProperty(exports, '__esModule', { value: true }); + +var events = require('events'); +var path = require('path'); +var url = require('url'); +var childProcess = require('child_process'); +var util = require('util'); + +function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; } + +var path__default = /*#__PURE__*/_interopDefaultLegacy(path); +var childProcess__default = /*#__PURE__*/_interopDefaultLegacy(childProcess); +var util__default = /*#__PURE__*/_interopDefaultLegacy(util); + +function getModulePaths (fileURL) { + const __filename = url.fileURLToPath(fileURL); + const __dirname = path__default['default'].dirname(__filename); + return { __filename, __dirname } +} + +const { __dirname: __dirname$1 } = getModulePaths((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href))); + +/* path to the HandbrakeCLI executable downloaded by the install script */ +let HandbrakeCLIPath = null; + +switch (process.platform) { + case 'darwin': + HandbrakeCLIPath = path__default['default'].join(__dirname$1, '..', 'bin', 'HandbrakeCLI'); + break + case 'win32': + HandbrakeCLIPath = path__default['default'].join(__dirname$1, '..', 'bin', 'HandbrakeCLI.exe'); + break + case 'linux': + HandbrakeCLIPath = 'HandBrakeCLI'; + break +} + +let last = null; + +const short = { + pattern: /\rEncoding: task (\d) of (\d), (.+) %/, + parse: function (progressString) { + const match = progressString.match(this.pattern); + if (match) { + const data = last = { + taskNumber: +match[1], + taskCount: +match[2], + percentComplete: +match[3], + fps: 0, + avgFps: 0, + eta: '', + task: 'Encoding' + }; + return data + } + } +}; + +const long = { + pattern: /\rEncoding: task (\d) of (\d), (.+) % \((.+) fps, avg (.+) fps, ETA (.+)\)/, + parse: function (progressString) { + const match = progressString.match(this.pattern); + if (match) { + const data = last = { + taskNumber: +match[1], + taskCount: +match[2], + percentComplete: +match[3], + fps: +match[4], + avgFps: +match[5], + eta: match[6], + task: 'Encoding' + }; + return data + } + } +}; + +const muxing = { + pattern: /\rMuxing: this may take awhile.../, + parse: function (progressString) { + const match = progressString.match(this.pattern); + if (match) { + const data = last = { + taskNumber: 0, + taskCount: 0, + percentComplete: 0, + fps: 0, + avgFps: 0, + eta: '', + task: 'Muxing' + }; + return data + } + } +}; + +/** + * @module object-to-spawn-args + */ + +/** + * @param {object} - an object specifying the command-line options to set + * @param [options] {object} + * @param [options.quote] {boolean} - enquote the option values + * @param [options.optionEqualsValue] {boolean} - use `--option=value` notation + */ +function toSpawnArgs (object, options) { + options = Object.assign({ + optionEqualsValueList: [], + optionEqualsValueExclusions: [], + }, options); + const output = []; + + for (const prop in object) { + const value = object[prop]; + if (value !== undefined) { + const dash = prop.length === 1 ? '-' : '--'; + if ((options.optionEqualsValue && !options.optionEqualsValueExclusions.includes(prop)) || options.optionEqualsValueList.includes(prop)) { + if (value === true) { + output.push(dash + prop); + } else { + if (Array.isArray(value)) { + output.push(dash + prop + '=' + quote(value.join(','), options.quote)); + } else { + output.push(dash + prop + '=' + quote(value, options.quote)); + } + } + } else { + output.push(dash + prop); + if (value !== true) { + if (Array.isArray(value)) { + value.forEach(function (item) { + output.push(quote(item, options.quote)); + }); + } else { + output.push(quote(value, options.quote)); + } + } + } + } + } + return output +} + +function quote (value, toQuote) { + return toQuote ? '"' + value + '"' : value +} + +var objectToSpawnArgs = toSpawnArgs; + +/** + * @class + * @classdesc A handle on the HandbrakeCLI process. Emits events you can monitor to track progress. An instance of this class is returned by {@link module:handbrake-js.spawn}. + * @extends external:EventEmitter + * @emits module:handbrake-js~Handbrake#event:start + * @emits module:handbrake-js~Handbrake#event:begin + * @emits module:handbrake-js~Handbrake#event:progress + * @emits module:handbrake-js~Handbrake#event:output + * @emits module:handbrake-js~Handbrake#event:error + * @emits module:handbrake-js~Handbrake#event:end + * @emits module:handbrake-js~Handbrake#event:complete + * @emits module:handbrake-js~Handbrake#event:cancelled + * @memberof module:handbrake-js + * @inner + */ +class Handbrake extends events.EventEmitter { + constructor (options = {}, mocks) { + super(); + /** + * A `string` containing all handbrakeCLI output + * @type {string} + */ + this.output = ''; + /* `true` while encoding */ + this._inProgress = false; + /** + * a copy of the options passed to {@link module:handbrake-js.spawn} + * @type {object} + */ + this.options = options; + + /* path to the HandbrakeCLI executable downloaded by the install script */ + this.HandbrakeCLIPath = options.HandbrakeCLIPath || HandbrakeCLIPath; + + /* for test scripts */ + this.cp = (mocks && mocks.cp) || childProcess__default['default']; + } + + /** + * Cancel the encode, kill the underlying HandbrakeCLI process then emit a `cancelled` event. + */ + cancel () { + if (this.handle) { + this.handle.on('close', (code, signal) => { + /* the first test is for mac/linux, second for windows */ + if (/Signal 2 received, terminating/.test(this.output) || (code === null && signal === 'SIGINT')) { + this._emitCancelled(); + } + }); + this.handle.kill('SIGINT'); + } + } + + /* ensure user has had chance to attach event listeners before calling */ + _run () { + let err = new Error(); + + if (this.options.input !== undefined && this.options.output !== undefined) { + const pathsEqual = path__default['default'].resolve(this.options.input) === path__default['default'].resolve(this.options.output); + if (pathsEqual) { + err.name = this.eError.VALIDATION; + err.message = 'input and output paths are the same'; + this._emitError(err); + return + } + } + + const spawnArgs = objectToSpawnArgs(this.options, { + optionEqualsValue: true, + optionEqualsValueExclusions: ['preset-import-file', 'preset-import-gui', 'subtitle-burned'] + }); + this._emitStart(); + const handle = this.cp.spawn(this.HandbrakeCLIPath, spawnArgs); + handle.stdout.setEncoding('utf-8'); + + let buffer = ''; + handle.stdout.on('data', chunk => { + buffer += chunk; + + if (long.pattern.test(buffer)) { + this._emitProgress(long.parse(buffer)); + buffer = buffer.replace(long.pattern, ''); + } else if (short.pattern.test(buffer)) { + this._emitProgress(short.parse(buffer)); + buffer = buffer.replace(short.pattern, ''); + } else if (muxing.pattern.test(buffer)) { + this._emitProgress(muxing.parse(buffer)); + buffer = buffer.replace(muxing.pattern, ''); + } + this._emitOutput(chunk); + }); + + handle.stderr.on('data', this._emitOutput.bind(this)); + + handle.on('exit', (code, signal) => { + /* ignore a cancelled exit, which is handled by .cancel() */ + /* the first test is for mac/linux, second for windows */ + if (/Signal 2 received, terminating/.test(this.output) || (code === null && signal === 'SIGINT')) { + return + } + + if (code === 0) { + if (this._inProgress) { + const last$1 = last; + if (last$1) { + last$1.percentComplete = 100; + this._emitProgress(last$1); + } + this._emitEnd(); + } + } else if (code === 1) { + err = new Error(); + err.name = this.eError.VALIDATION; + err.message = 'User input validation error [error code: ' + code + ']'; + err.errno = code; + this._emitError(err); + } else if (code === 2) { + err = new Error(); + if (/invalid preset/i.test(this.output)) { + err.name = this.eError.INVALID_PRESET; + err.message = 'Invalid preset [error code: ' + code + ']'; + } else { + err.name = this.eError.INVALID_INPUT; + err.message = 'Invalid input, not a video file [error code: ' + code + ']'; + } + this._emitError(err); + } else if (code === 3) { + err = new Error(); + err.name = this.eError.OTHER; + err.message = 'Handbrake InitialisationError [error code: ' + code + ']'; + this._emitError(err); + } else if (code === 4) { + err = new Error(); + err.name = this.eError.OTHER; + err.message = 'Unknown Handbrake error [error code: ' + code + ']'; + this._emitError(err); + } else if (code === null) { + err = new Error(); + err.name = this.eError.OTHER; + err.message = 'HandbrakeCLI crashed (Segmentation fault)'; + this._emitError(err); + } + this._emitComplete(); + }); + + handle.on('error', spawnError => { + err.errno = spawnError.errno; + err.HandbrakeCLIPath = this.HandbrakeCLIPath; + if (spawnError.code === 'ENOENT') { + err.name = this.eError.NOT_FOUND; + err.message = 'HandbrakeCLI application not found: ' + err.HandbrakeCLIPath + '. Linux users must install HandbrakeCLI manually, please see https://handbrake.fr/downloads.php.'; + err.spawnmessage = spawnError.message; + } else { + err.name = this.eError.OTHER; + err.message = spawnError.message; + } + this._emitError(err); + this._emitComplete(); + }); + + this.handle = handle; + } + + /** + * Fired as HandbrakeCLI is launched. Nothing has happened yet. + * @event module:handbrake-js~Handbrake#start + */ + _emitStart () { + this.emit('start'); + } + + /** + * Fired when encoding begins. If you're expecting an encode and this never fired, something went wrong. + * @event module:handbrake-js~Handbrake#begin + */ + _emitBegin () { + this._inProgress = true; + this.emit('begin'); + } + + /** + * Fired at regular intervals passing a `progress` object. + * + * @event module:handbrake-js~Handbrake#progress + * @param progress {object} - details of encode progress + * @param progress.taskNumber {number} - current task index + * @param progress.taskCount {number} - total tasks in the queue + * @param progress.percentComplete {number} - percent complete + * @param progress.fps {number} - Frames per second + * @param progress.avgFps {number} - Average frames per second + * @param progress.eta {string} - Estimated time until completion + * @param progress.task {string} - Task description, either "Encoding" or "Muxing" + */ + _emitProgress (progress) { + if (!this._inProgress) this._emitBegin(); + this.emit('progress', progress); + } + + /** + * @event module:handbrake-js~Handbrake#output + * @param output {string} - An aggregate of `stdout` and `stderr` output from the underlying HandbrakeCLI process. + */ + _emitOutput (output) { + this.output += output; + if (/unknown option/.test(output.toString())) { + const err = new Error(); + err.name = this.eError.OTHER; + err.message = 'HandbrakeCLI reported "unknown option", please report this issue: https://github.com/75lb/handbrake-js/issues/new'; + this._emitError(err); + } else { + this.emit('output', output); + } + } + + /** + * @event module:handbrake-js~Handbrake#error + * @param error {Error} - All operational exceptions are delivered via this event. + * @param error.name {module:handbrake-js~Handbrake#eError} - The unique error identifier + * @param error.message {string} - Error description + * @param error.errno {string} - The HandbrakeCLI return code + */ + _emitError (err) { + err.output = this.output; + err.options = this.options; + this.emit('error', err); + } + + /** + * Fired on successful completion of an encoding task. Always follows a {@link module:handbrake-js~Handbrake#event:begin} event, with some {@link module:handbrake-js~Handbrake#event:progress} in between. + * @event module:handbrake-js~Handbrake#end + */ + _emitEnd () { + this.emit('end'); + } + + /** + * Fired when HandbrakeCLI exited cleanly. This does not necessarily mean your encode completed as planned.. + * @event module:handbrake-js~Handbrake#complete + */ + _emitComplete () { + this.emit('complete'); + } + + /** + * If `.cancel()` was called, this event is emitted once the underlying HandbrakeCLI process has closed. + * @event module:handbrake-js~Handbrake#cancelled + */ + _emitCancelled () { + this.emit('cancelled'); + } +} + +/** + * All operational errors are emitted via the {@link module:handbrake-js~Handbrake#event:error} event. + * @enum + * @memberof module:handbrake-js + * @inner + */ +Handbrake.prototype.eError = { + /** + * Thrown if you accidentally set identical input and output paths (which would clobber the input file), forget to specifiy an output path and other validation errors. + */ + VALIDATION: 'ValidationError', + /** + * Thrown when the input file specified does not appear to be a video file. + */ + INVALID_INPUT: 'InvalidInput', + /** + * Thrown when an invalid preset is specified. + */ + INVALID_PRESET: 'InvalidPreset', + /** + * Thrown if Handbrake crashes. + */ + OTHER: 'Other', + /** + * Thrown if the installed HandbrakeCLI binary has gone missing. + */ + NOT_FOUND: 'HandbrakeCLINotFound' +}; + +var cliOptions = [ + { name: 'help', type: Boolean, alias: 'h', group: 'general' }, + { name: 'version', type: Boolean, group: 'general' }, + { name: 'verbose', type: Boolean, alias: 'v', group: 'general' }, + { name: 'preset', type: String, alias: 'Z', group: 'general' }, + { name: 'preset-list', type: Boolean, alias: 'z', group: 'general' }, + { name: 'preset-import-file', type: String, group: 'general' }, + { name: 'preset-export', type: String, group: 'general' }, + { name: 'no-dvdnav', type: Boolean, group: 'general' }, + { name: 'no-opencl', type: Boolean, group: 'general' }, + + { name: 'input', type: String, alias: 'i', group: 'source' }, + { name: 'title', type: Number, alias: 't', group: 'source' }, + { name: 'min-duration', type: Number, group: 'source' }, + { name: 'scan', type: Boolean, group: 'source' }, + { name: 'main-feature', type: Boolean, group: 'source' }, + { name: 'chapters', type: String, alias: 'c', group: 'source' }, + { name: 'angle', type: Number, group: 'source' }, + { name: 'previews', type: String, group: 'source' }, + { name: 'start-at-preview', type: String, group: 'source' }, + { name: 'start-at', type: String, group: 'source' }, + { name: 'stop-at', type: String, group: 'source' }, + + { name: 'output', type: String, alias: 'o', group: 'destination' }, + { name: 'format', type: String, alias: 'f', group: 'destination' }, + { name: 'markers', type: Boolean, alias: 'm', group: 'destination' }, + { name: 'no-markers', type: Boolean, group: 'destination' }, + { name: 'optimize', type: Boolean, alias: 'O', group: 'destination' }, + { name: 'ipod-atom', type: Boolean, alias: 'I', group: 'destination' }, + { name: 'no-ipod-atom', type: Boolean, group: 'destination' }, + { name: 'use-opencl', type: Boolean, alias: 'P', group: 'destination' }, + + { name: 'encoder', type: String, alias: 'e', group: 'video' }, + { name: 'encoder-preset', type: String, group: 'video' }, + { name: 'encoder-preset-list', type: String, group: 'video' }, + { name: 'encoder-tune', type: String, group: 'video' }, + { name: 'encoder-tune-list', type: String, group: 'video' }, + { name: 'encopts', type: String, alias: 'x', group: 'video' }, + { name: 'encoder-profile', type: String, group: 'video' }, + { name: 'encoder-profile-list', type: String, group: 'video' }, + { name: 'encoder-level', type: String, group: 'video' }, + { name: 'encoder-level-list', type: String, group: 'video' }, + { name: 'quality', type: Number, alias: 'q', group: 'video' }, + { name: 'vb', type: Number, alias: 'b', group: 'video' }, + { name: 'two-pass', type: Boolean, group: 'video' }, + { name: 'no-two-pass', type: Boolean, group: 'video' }, + { name: 'turbo', type: Boolean, alias: 'T', group: 'video' }, + { name: 'no-turbo', type: Boolean, group: 'video' }, + { name: 'rate', type: Number, alias: 'r', group: 'video' }, + { name: 'vfr', type: Boolean, group: 'video' }, + { name: 'cfr', type: Boolean, group: 'video' }, + { name: 'pfr', type: Boolean, group: 'video' }, + + { name: 'audio-lang-list', type: String, group: 'audio' }, + { name: 'all-audio', type: Boolean, group: 'audio' }, + { name: 'first-audio', type: Boolean, group: 'audio' }, + { name: 'audio', type: String, alias: 'a', group: 'audio' }, + { name: 'aencoder', type: String, alias: 'E', group: 'audio' }, + { name: 'audio-copy-mask', type: String, group: 'audio' }, + { name: 'audio-fallback', type: String, group: 'audio' }, + { name: 'ab', type: String, alias: 'B', group: 'audio' }, + { name: 'aq', type: String, alias: 'Q', group: 'audio' }, + { name: 'ac', type: String, alias: 'C', group: 'audio' }, + { name: 'mixdown', type: String, group: 'audio' }, + { name: 'normalize-mix', type: String, group: 'audio' }, + { name: 'arate', type: String, alias: 'R', group: 'audio' }, + { name: 'drc', type: Number, alias: 'D', group: 'audio' }, + { name: 'gain', type: Number, group: 'audio' }, + { name: 'adither', type: String, group: 'audio' }, + { name: 'aname', type: String, alias: 'A', group: 'audio' }, + + { name: 'width', type: Number, alias: 'w', group: 'picture' }, + { name: 'height', type: Number, alias: 'l', group: 'picture' }, + { name: 'crop', type: String, group: 'picture' }, + { name: 'loose-crop', type: Boolean, group: 'picture' }, + { name: 'no-loose-crop', type: Boolean, group: 'picture' }, + { name: 'maxHeight', type: Number, alias: 'Y', group: 'picture' }, + { name: 'maxWidth', type: Number, alias: 'X', group: 'picture' }, + { name: 'non-anamorphic', type: Boolean, group: 'picture' }, + { name: 'auto-anamorphic', type: Boolean, group: 'picture' }, + { name: 'loose-anamorphic', type: Boolean, group: 'picture' }, + { name: 'custom-anamorphic', type: Boolean, group: 'picture' }, + { name: 'display-width', type: Number, group: 'picture' }, + { name: 'keep-display-aspect', type: Boolean, group: 'picture' }, + { name: 'pixel-aspect', type: String, group: 'picture' }, + { name: 'itu-par', type: Boolean, group: 'picture' }, + { name: 'modulus', type: Number, group: 'picture' }, + { name: 'color-matrix', type: String, alias: 'M', group: 'picture' }, + + { name: 'comb-detect', type: String, group: 'filters' }, + { name: 'no-comb-detect', type: Boolean, group: 'filters' }, + { name: 'deinterlace', type: String, alias: 'd', group: 'filters' }, + { name: 'no-deinterlace', type: Boolean, group: 'filters' }, + { name: 'decomb', type: String, group: 'filters' }, + { name: 'no-decomb', type: Boolean, group: 'filters' }, + { name: 'detelecine', type: String, group: 'filters' }, + { name: 'no-detelecine', type: Boolean, group: 'filters' }, + { name: 'hqdn3d', type: String, group: 'filters' }, + { name: 'no-hqdn3d', type: Boolean, group: 'filters' }, + { name: 'denoise', type: String, group: 'filters' }, + { name: 'nlmeans', type: String, group: 'filters' }, + { name: 'no-nlmeans', type: Boolean, group: 'filters' }, + { name: 'nlmeans-tune', type: String, group: 'filters' }, + { name: 'deblock', type: String, group: 'filters' }, + { name: 'no-deblock', type: Boolean, group: 'filters' }, + { name: 'rotate', type: String, group: 'filters' }, + { name: 'pad', type: String, group: 'filters' }, + { name: 'grayscale', type: Boolean, alias: 'g', group: 'filters' }, + { name: 'no-grayscale', type: Boolean, group: 'filters' }, + + { name: 'subtitle-lang-list', type: String, group: 'subtitle' }, + { name: 'all-subtitles', type: Boolean, group: 'subtitle' }, + { name: 'first-subtitles', type: Boolean, group: 'subtitle' }, + { name: 'subtitle', type: String, alias: 's', group: 'subtitle' }, + { name: 'subtitle-forced', type: Number, alias: 'F', group: 'subtitle' }, + { name: 'subtitle-burned', type: Number, group: 'subtitle' }, + { name: 'subtitle-default', type: Number, group: 'subtitle' }, + { name: 'native-language', type: String, alias: 'N', group: 'subtitle' }, + { name: 'native-dub', type: Boolean, group: 'subtitle' }, + { name: 'srt-file', type: String, group: 'subtitle' }, + { name: 'srt-codeset', type: String, group: 'subtitle' }, + { name: 'srt-offset', type: String, group: 'subtitle' }, + { name: 'srt-lang', type: String, group: 'subtitle' }, + { name: 'srt-default', type: Number, group: 'subtitle' }, + { name: 'srt-burn', type: Number, group: 'subtitle' } +]; + +/** + * Handbrake for node.js. + * @module handbrake-js + * @typicalname hbjs + * @example + * ```js + * const hbjs = require('handbrake-js') + * ``` + */ + +/** + * Spawns a HandbrakeCLI process with the supplied [options](https://handbrake.fr/docs/en/latest/cli/cli-guide.html#options), returning an instance of `Handbrake` on which you can listen for events. + * + * @param {object} [options] - [Options](https://handbrake.fr/docs/en/latest/cli/cli-guide.html#options) to pass directly to HandbrakeCLI + * @param {string} [options.HandbrakeCLIPath] - Override the built-in `HandbrakeCLI` binary path. + * @returns {module:handbrake-js~Handbrake} + * @alias module:handbrake-js.spawn + * @example + * ```js + * const hbjs = require('handbrake-js') + * + * const options = { + * input: 'something.avi', + * output: 'something.mp4', + * preset: 'Normal', + * rotate: 1 + * } + * hbjs.spawn(options) + * .on('error', console.error) + * .on('output', console.log) + * ``` + */ +function spawn (options = {}, mocks) { + const handbrake = new Handbrake(options, mocks); + + /* defer so the caller can attach event listers on the returned Handbrake instance first */ + process.nextTick(function () { + try { + handbrake._run(); + } catch (error) { + const err = new Error(); + err.message = error.message; + err.name = 'InvalidOption'; + handbrake._emitError(err); + } + }); + + return handbrake +} + +/** + * Runs HandbrakeCLI with the supplied [options](https://handbrake.fr/docs/en/latest/cli/cli-guide.html#options) calling the supplied callback on completion. The exec method is best suited for short duration tasks where you can wait until completion for the output. + * + * @param options {Object} - [Options](https://handbrake.fr/docs/en/latest/cli/cli-guide.html#options) to pass directly to HandbrakeCLI + * @param {string} [options.HandbrakeCLIPath] - Override the built-in `HandbrakeCLI` binary path. + * @param [onComplete] {Function} - If passed, `onComplete(err, stdout, stderr)` will be called on completion, `stdout` and `stderr` being strings containing the HandbrakeCLI output. + * + * @example + * ```js + * const hbjs = require('handbrake-js') + * + * hbjs.exec({ preset-list: true }, function(err, stdout, stderr){ + * if (err) throw err + * console.log(stdout) + * }) + * ``` + * @alias module:handbrake-js.exec + */ +function exec (options = {}, done) { + const cmd = util__default['default'].format( + '"%s" %s', + options.HandbrakeCLIPath || HandbrakeCLIPath, + objectToSpawnArgs(options, { quote: true }).join(' ') + ); + childProcess__default['default'].exec(cmd, done); +} + +/** + * Identical to `hbjs.exec` except it returns a promise, rather than invoke a callback. Use this when you don't need the progress events reported by `hbjs.spawn`. Fulfils with an object containing the output in two properties: `stdout` and `stderr`. + * @param options {Object} - [Options](https://handbrake.fr/docs/en/latest/cli/cli-guide.html#options) to pass directly to HandbrakeCLI + * @param {string} [options.HandbrakeCLIPath] - Override the built-in `HandbrakeCLI` binary path. + * @returns {Promise} + * @example + * ```js + * const hbjs = require('handbrake-js') + * + * async function start () { + * const result = await hbjs.run({ version: true }) + * console.log(result.stdout) + * // prints 'HandBrake 1.3.0' + * } + * + * start().catch(console.error) + * ``` + * @alias module:handbrake-js.run + */ +async function run (options) { + return new Promise((resolve, reject) => { + exec(options, function (err, stdout, stderr) { + if (err) { + reject(err); + } else { + resolve({ stdout, stderr }); + } + }); + }) +} +var index = { cliOptions, spawn, exec, run }; + +exports.cliOptions = cliOptions; +exports['default'] = index; +exports.exec = exec; +exports.run = run; +exports.spawn = spawn; diff --git a/package-lock.json b/package-lock.json index db3f667..4cbb758 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,10 @@ "handbrake": "bin/cli.js" }, "devDependencies": { + "@rollup/plugin-commonjs": "^20.0.0", + "@rollup/plugin-node-resolve": "^13.0.4", "jsdoc-to-markdown": "^7.0.1", + "rollup": "^2.56.3", "sleep-anywhere": "^2.0.1", "test-runner": "^0.9.8" }, @@ -42,6 +45,70 @@ "node": ">=6.0.0" } }, + "node_modules/@rollup/plugin-commonjs": { + "version": "20.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-20.0.0.tgz", + "integrity": "sha512-5K0g5W2Ol8hAcTHqcTBHiA7M58tfmYi1o9KxeJuuRNpGaTa5iLjcyemBitCBcKXaHamOBBEH2dGom6v6Unmqjg==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^2.38.3" + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "13.0.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.0.4.tgz", + "integrity": "sha512-eYq4TFy40O8hjeDs+sIxEH/jc9lyuI2k9DM557WN6rO5OpnC2qXMBNj4IKH1oHrnAazL49C5p0tgP0/VpqJ+/w==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.19.0" + }, + "engines": { + "node": ">= 10.0.0" + }, + "peerDependencies": { + "rollup": "^2.42.0" + } + }, + "node_modules/@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "dependencies": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "engines": { + "node": ">= 8.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0" + } + }, + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + }, "node_modules/@test-runner/core": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/@test-runner/core/-/core-0.10.0.tgz", @@ -181,6 +248,27 @@ "node": ">=12.17" } }, + "node_modules/@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, + "node_modules/@types/node": { + "version": "16.9.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", + "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==", + "dev": true + }, + "node_modules/@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/ansi-escape-sequences": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-6.2.0.tgz", @@ -323,6 +411,18 @@ "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" }, + "node_modules/builtin-modules": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", + "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/cache-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/cache-point/-/cache-point-2.0.0.tgz", @@ -554,6 +654,12 @@ "node": ">=8" } }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, "node_modules/composite-class": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/composite-class/-/composite-class-2.0.1.tgz", @@ -714,6 +820,15 @@ "node": ">=4.0.0" } }, + "node_modules/deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/dmd": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/dmd/-/dmd-6.0.0.tgz", @@ -769,6 +884,12 @@ "node": ">=8" } }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "node_modules/fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", @@ -866,6 +987,20 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/fsm-base": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/fsm-base/-/fsm-base-0.7.0.tgz", @@ -879,6 +1014,12 @@ "node": ">=14" } }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, "node_modules/get-stream": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", @@ -936,6 +1077,18 @@ "uglify-js": "^3.1.4" } }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -978,11 +1131,38 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "node_modules/is-core-module": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", + "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, "node_modules/is-natural-number": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", "integrity": "sha1-q5124dtM7VHjXeDHLr7PCfc0zeg=" }, + "node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, "node_modules/is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -1168,6 +1348,15 @@ "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=", "dev": true }, + "node_modules/magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "dependencies": { + "sourcemap-codec": "^1.4.4" + } + }, "node_modules/make-dir": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", @@ -1334,11 +1523,29 @@ "node": ">=0.10.0" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, "node_modules/pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" }, + "node_modules/picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, "node_modules/pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -1512,6 +1719,19 @@ "lodash": "^4.17.14" } }, + "node_modules/resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "dependencies": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -1526,6 +1746,21 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/rollup": { + "version": "2.56.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.3.tgz", + "integrity": "sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg==", + "dev": true, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=10.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1606,6 +1841,12 @@ "node": ">=0.10.0" } }, + "node_modules/sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "dev": true + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -2088,6 +2329,54 @@ "integrity": "sha512-2hQstc6I7T6tQsWzlboMh3SgMRPaS4H6H7cPQsJkdzTzEGqQrpLDsE2BGASU5sBPoEQyHzeqU6C8uKbFeEk6sg==", "dev": true }, + "@rollup/plugin-commonjs": { + "version": "20.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-20.0.0.tgz", + "integrity": "sha512-5K0g5W2Ol8hAcTHqcTBHiA7M58tfmYi1o9KxeJuuRNpGaTa5iLjcyemBitCBcKXaHamOBBEH2dGom6v6Unmqjg==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "commondir": "^1.0.1", + "estree-walker": "^2.0.1", + "glob": "^7.1.6", + "is-reference": "^1.2.1", + "magic-string": "^0.25.7", + "resolve": "^1.17.0" + } + }, + "@rollup/plugin-node-resolve": { + "version": "13.0.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-13.0.4.tgz", + "integrity": "sha512-eYq4TFy40O8hjeDs+sIxEH/jc9lyuI2k9DM557WN6rO5OpnC2qXMBNj4IKH1oHrnAazL49C5p0tgP0/VpqJ+/w==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.19.0" + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + }, + "dependencies": { + "estree-walker": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", + "dev": true + } + } + }, "@test-runner/core": { "version": "0.10.0", "resolved": "https://registry.npmjs.org/@test-runner/core/-/core-0.10.0.tgz", @@ -2199,6 +2488,27 @@ } } }, + "@types/estree": { + "version": "0.0.39", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", + "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", + "dev": true + }, + "@types/node": { + "version": "16.9.1", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.9.1.tgz", + "integrity": "sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==", + "dev": true + }, + "@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "ansi-escape-sequences": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/ansi-escape-sequences/-/ansi-escape-sequences-6.2.0.tgz", @@ -2309,6 +2619,12 @@ "resolved": "https://registry.npmjs.org/buffer-fill/-/buffer-fill-1.0.0.tgz", "integrity": "sha1-+PeLdniYiO858gXNY39o5wISKyw=" }, + "builtin-modules": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", + "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "dev": true + }, "cache-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/cache-point/-/cache-point-2.0.0.tgz", @@ -2503,6 +2819,12 @@ "integrity": "sha512-jAg09gkdkrDO9EWTdXfv80WWH3yeZl5oT69fGfedBNS9pXUKYInVJ1bJ+/ht2+Moeei48TmSbQDYMc8EOx9G0g==", "dev": true }, + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, "composite-class": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/composite-class/-/composite-class-2.0.1.tgz", @@ -2630,6 +2952,12 @@ "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", "dev": true }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, "dmd": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/dmd/-/dmd-6.0.0.tgz", @@ -2678,6 +3006,12 @@ "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", "dev": true }, + "estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "fd-slicer": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz", @@ -2748,6 +3082,13 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true + }, "fsm-base": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/fsm-base/-/fsm-base-0.7.0.tgz", @@ -2758,6 +3099,12 @@ "obso": "^0.7.0" } }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", + "dev": true + }, "get-stream": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-2.3.1.tgz", @@ -2798,6 +3145,15 @@ "wordwrap": "^1.0.0" } }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1" + } + }, "has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -2823,11 +3179,35 @@ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "is-core-module": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.6.0.tgz", + "integrity": "sha512-wShG8vs60jKfPWpF2KZRaAtvt3a20OAn7+IJ6hLPECpSABLcKtFKTTI4ZtH5QcBruBHlq+WsdHWyz0BCZW7svQ==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, "is-natural-number": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/is-natural-number/-/is-natural-number-4.0.1.tgz", "integrity": "sha1-q5124dtM7VHjXeDHLr7PCfc0zeg=" }, + "is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "requires": { + "@types/estree": "*" + } + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -2987,6 +3367,15 @@ "integrity": "sha1-UvBWEP/53tQiYRRB7R/BI6AwAbM=", "dev": true }, + "magic-string": { + "version": "0.25.7", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", + "integrity": "sha512-4CrMT5DOHTDk4HYDlzmwu4FVCcIYI8gauveasrdCu2IKIFOJ3f0v/8MDGJCDL9oD2ppz/Av1b0Nj345H9M+XIA==", + "dev": true, + "requires": { + "sourcemap-codec": "^1.4.4" + } + }, "make-dir": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", @@ -3110,11 +3499,23 @@ "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, "pend": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=" }, + "picomatch": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", + "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", + "dev": true + }, "pify": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", @@ -3258,6 +3659,16 @@ "lodash": "^4.17.14" } }, + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + }, "rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -3266,6 +3677,15 @@ "glob": "^7.1.3" } }, + "rollup": { + "version": "2.56.3", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-2.56.3.tgz", + "integrity": "sha512-Au92NuznFklgQCUcV96iXlxUbHuB1vQMaH76DHl5M11TotjOHwqk9CwcrT78+Tnv4FN9uTBxq6p4EJoYkpyekg==", + "dev": true, + "requires": { + "fsevents": "~2.3.2" + } + }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -3315,6 +3735,12 @@ "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, + "sourcemap-codec": { + "version": "1.4.8", + "resolved": "https://registry.npmjs.org/sourcemap-codec/-/sourcemap-codec-1.4.8.tgz", + "integrity": "sha512-9NykojV5Uih4lgo5So5dtw+f0JgJX30KCNI8gwhz2J9A15wD0Ml6tjHKwf6fTSa6fAdVBdZeNOs9eJ71qCk8vA==", + "dev": true + }, "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", diff --git a/package.json b/package.json index 3289f2f..7f761cf 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,14 @@ "files": [ "bin/cli.js", "lib", + "dist", "scripts", "index.js" ], "scripts": { - "test": "npm run test:ci", + "test": "npm run dist && npm run test:ci", "test:ci": "test-runner test/*.js", + "dist": "rollup -c", "postinstall": "node scripts/install.js", "ubuntu-setup": "./scripts/install-ubuntu.sh", "docs": "jsdoc2md -t README.hbs lib/*.js index.js > README.md" @@ -52,7 +54,10 @@ "rimraf": "^3.0.2" }, "devDependencies": { + "@rollup/plugin-commonjs": "^20.0.0", + "@rollup/plugin-node-resolve": "^13.0.4", "jsdoc-to-markdown": "^7.0.1", + "rollup": "^2.56.3", "sleep-anywhere": "^2.0.1", "test-runner": "^0.9.8" }, diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 0000000..b966b53 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,15 @@ +import { nodeResolve } from '@rollup/plugin-node-resolve' +import commonJs from '@rollup/plugin-commonjs' + +export default [ + { + input: 'index.js', + output: { + file: 'dist/index.cjs', + format: 'cjs', + exports: 'auto' + }, + external: [], + plugins: [nodeResolve({ preferBuiltins: true }), commonJs()] + } +]