'use strict';

// Load requirements
const engine = require('../engine'),
      moment = require('moment');

// Export for use
module.exports = {

  // Helps avoid errors when engine quits without starting
  progressBar: {terminate: function() { }},

  // Track the time since conversion began
  started: moment(),

  // Configures and runs the conversion task
  run: function(job) {
    return new Promise((resolve, reject) => {

      // Check we got a file at all
      if ( ! job ) {
        return reject('No job data provided');
      }

      // Configure the conversion engine command
      let command = engine.config(job.file, job.options, job.meta, (err) => {
        return reject(err);
      });

      // Bind events
      ['start', 'filenames', 'progress', 'error', 'end'].forEach((e) => {
        return command.on(e, function() {
            
          // Format arguments to include details and metadata
          let args = Array.prototype.slice.call(arguments);
          args.push(job, job.meta);
            
          // Call event callback with args
          this['on' + e].apply(this, args);
        }.bind(this));
      });

      // Start processing the job
      return command.run();
    });
  },

  onstart: require('./events/start'),

  onfilenames: require('./events/filenames'),

  onprogress: require('./events/progress'),

  onerror: require('./events/error'),

  onend: require('./events/end')

};

@@ -29,16 +29,163 @@
 rements%0A
+const moment = require('moment'),%0A      filesize = require('filesize'),%0A      path = require('path'),%0A      fs = require('fs');%0A%0A// Load libraries%0A
 const en
@@ -219,22 +219,21 @@
 ,%0A      
-moment
+utils
  = requi
@@ -236,22 +236,24 @@
 equire('
-moment
+../utils
 ');%0A%0A// 
@@ -839,16 +839,16 @@
 t(err);%0A
-
       %7D)
@@ -842,32 +842,557 @@
 rr);%0A      %7D);%0A%0A
+      // Add additional details%0A      job.output    = path.resolve('./sample.mp4'); // Temporary until engine is more advanced%0A      job.temp      = path.resolve('./sample.mp4'); // Temporary until engine is more advanced%0A      job.framerate = utils.framerate(job.meta.streams%5B0%5D.avg_frame_rate);%0A      job.started = this.started.format('MMMM Do YYYY, h:mm:ss a');%0A      job.size = %7B%0A        original: %7B%0A          raw: fs.statSync(job.file).size,%0A          formatted: filesize(fs.statSync(job.file).size)%0A        %7D%0A      %7D;%0A%0A
       // Bind ev

Add additional information to conversion start