lib/index.js
function addAllMtimes(files, metalsmith, done) {

  var source = metalsmith.source();

  // File system will be accessed for each element so iterate in parallel.
  each(Object.keys(files), getAddMtime, done);


  /**
   * Gets mtime of given `file` and adds it to metadata.
   *
   * @param {String} file
   * @param {Function} done
   * @api private
   */

  function getAddMtime(file, done) {
    fs.stat(path.join(source, file), addMtime);


    /**
     * Adds `stats.mtime` of `file` to its metadata.
     *
     * @param {Error} err
     * @param {fs.Stats} stats
     * @api private
     */

    function addMtime(err, stats) {
      if (err) {
        // Skip elements of `files` that don't point to existing files.
        // This can happen if some other Metalsmith plugin does something
        // strange with `files`.
        if (err.code === 'ENOENT') {
          debug('file %s not found', file);
          return done();
        }
        return done(err);
      }

      debug('mtime of file %s is %s', file, stats.mtime);
      files[file].mtime = stats.mtime;
      done();
    }
  }
}
function addAllMtimes(files, metalsmith, done) {

  var source = metalsmith.source();

  // File system will be accessed for each element so iterate in parallel.
  each(Object.keys(files), getAddMtime, done);


  /**
   * Gets mtime of given `file` and adds it to metadata.
   *
   * @param {String} file
   * @param {Function} done
   * @api private
   */

  function getAddMtime(file, done) {
    fs.stat(path.join(source, file), addMtime);


    /**
     * Adds `stats.mtime` of `file` to its metadata.
     *
     * @param {Error} err
     * @param {fs.Stats} stats
     * @api private
     */

    function addMtime(err, stats) {
      if (err) {
        // Skip elements of `files` that don't point to existing files.
        // This can happen if some other Metalsmith plugin does something
        // strange with `files`.
        if (err.code === 'ENOENT') {
          debug('file %s not found', file);
          return done();
        }
        return done(err);
      }

      debug('mtime of file %s is %s', file, stats.mtime);
      files[file].mtime = stats.mtime;
      done();
    }
  }
}
function addAllMtimes ( files , metalsmith , done ) { var source = metalsmith . source ( ) ; // File system will be accessed for each element so iterate in parallel. each ( Object . keys ( files ) , getAddMtime , done ) ; /**
   * Gets mtime of given `file` and adds it to metadata.
   *
   * @param {String} file
   * @param {Function} done
   * @api private
   */ function getAddMtime ( file , done ) { fs . stat ( path . join ( source , file ) , addMtime ) ; /**
     * Adds `stats.mtime` of `file` to its metadata.
     *
     * @param {Error} err
     * @param {fs.Stats} stats
     * @api private
     */ function addMtime ( err , stats ) { if ( err ) { // Skip elements of `files` that don't point to existing files. // This can happen if some other Metalsmith plugin does something // strange with `files`. if ( err . code === 'ENOENT' ) { debug ( 'file %s not found' , file ) ; return done ( ) ; } return done ( err ) ; } debug ( 'mtime of file %s is %s' , file , stats . mtime ) ; files [ file ] . mtime = stats . mtime ; done ( ) ; } } }
Adds files mtimes to all corresponding objects in `files`.

@param {Object} files
@param {Object} metalsmith
@param {Function} done
@api private
Adds files mtimes to all corresponding objects in files .