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M,OAAO,EAAI,GAErB,EAAI,KACN,GAEF,KAnByB,EAAI,KAoB/B,GAEJ,CAtMA,IAAK,oCAAqC,GAC1C,KAAM,wCAAyC,IAIE,IAA7C,EAAgB,QAAS,eAE3B,IAAK,oEAEL,aAAc,EAAY,EAAU,cAAc,SAAU,EAAK,GAC/D,GAAI,EAAM,OAAO,EAAI,GAErB,EAAO,EACH,GAAY,YAAa,GAC7B,GACF,MAEA,IAAK,mEACL,EAAO,EACP,IAoLJ,GAEJ","file":"/npm/ryver@0.1.19/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/ryver@0.1.19/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\nvar async = require('async');\nvar fs = require('fs-extra')\nvar nodeFs = require('fs')\nvar p = require('path')\nvar EventEmitterCollector = require(\"eventemittercollector\");\nvar mmm = require('mmmagic');\nvar DO = require('deepobject');\nvar yaml = require('js-yaml');\nvar chalk = require('chalk');\n\nvar Magic = mmm.Magic;\nvar magic = new Magic( mmm.MAGIC_MIME_TYPE );\n\n/* TODO:\n  * [ ] Change ryver-lister so that it returns proper extra things to filter rather than \"the lot\"\n  * [ ] MAYBE do filter_include: https://github.com/leizongmin/tinyliquid/issues/33#issuecomment-118792483\n  * [ ] Make default file structure for themes\n*/\n\n// Private module variables\n// (Not exported)\n\nvar processing = {\n  filters: {},\n  src: null,\n  dst: null,\n  verbose: 0,\n  toPostProcess: [],\n  config: {},\n  mainInfo: {},\n  yamlCache: {},\n  watch: false,\n};\n\n// Public module variables\n// (Exported)\n\nvar eventEC = exports.eventEC = new EventEmitterCollector;\n\n// Signal management\neventEC.onCollect( 'watch', function( cb ){\n\n  var f = function( op, URL, cb ){\n    vlog( \"main: Operation\", op, \"on\", URL );\n\n    // If _config.yaml is changed, it's game over\n    if( URL === \"_config.yaml\" ){\n      console.log(\"Config file changed, exiting execution...\" );\n      process.exit( 0 );\n    }\n\n    // It will only care about _info.yaml\n    if( p.basename( URL ) !== '_info.yaml' ) {\n      vlog(\"main-info-watch: Ignoring file since it's not called _info.yaml\");\n      return cb( null );\n    }\n\n    // Make up filePath and fileNameAndExt\n    var filePath = p.dirname( URL);\n    var fileNameAndExt = p.basename( URL );\n\n    // If filePath is empty, dirname returns '.'. Change it to '.'\n    if( filePath === '.' ) filePath = '';\n\n    // Read the YAML file, which will also update the cache\n    readYamlFile( {}, filePath, fileNameAndExt, function( err, newObject, yamlData ){\n      log( \"Cached of _info.yaml files changed to: \", processing.yamlCache[ URL ] );\n      cb( null );\n    });\n  }\n\n  // Return the function just defined as the filter\n  cb( null, { name: 'main-info-watch', executor: f } );\n});\n\n\n// Private module methods\n\nvar deleteTrailingSlash = function( src ){\n  var lastIndex = src.length -1;\n  if( src[ lastIndex ] == '/' )\n    return src.substr(0, lastIndex )\n  else\n    return src;\n}\n\nvar addHooksToList = function( list, hookName, front ){\n\n  var hooks = processing.filterHooks[ hookName ];\n\n  log( \"Adding hooks to filtersPipeline for hook\", hookName );\n  if( ! hooks.length ){\n    log( 'No hooks registered for ', hookName );\n    log( 'Adding dummy hook...' );\n    list.push( { type: 'hook', name: 'dummy', hookName: hookName, func: function( o, cb ){ cb( null ); } });\n    return;\n  } else {\n    log(\"Hooks registered for \", hookName,\":\", hooks.length );\n  }\n\n\n  // If 'front' is set, then hooks will be added by cycling them and\n  // 'unshifting' the `hooks` variable, which will by definition reverse\n  // the order in which the callbacks are added. This could potentially\n  // have side effects on modules that want callbacks to be run in a\n  // specific order (e.g. ryver-lister, which wants to create/sort the list,\n  // and THEN make up a (ordered) short list for a specific page.\n  // So, if `front` is defined, the list of hooks is reversed and then unshifted.\n  var newHooks;\n  if( front ) {\n    newHooks = hooks.concat().reverse();\n  } else {\n    newHooks = hooks;\n  }\n\n  newHooks.forEach( function( hook ){\n    if( front ){\n      log( \"Adding function to the top of the list\" );\n      list.unshift( { type: 'hook', name: hook.name, func: hook.executor, hookName: hookName } );\n    }  else {\n      log( \"Adding function to the bottom of the list\" );\n      list.push( { type: 'hook', name: hook.name, func: hook.executor, hookName: hookName } );\n    }\n  });\n}\n\n\nvar addFiltersToList = function( list, commaSeparatedFilters ){\n\n  log( \"Adding filters to filtersPipeline:\", commaSeparatedFilters );\n\n  // Make up the list as array, and give up if it was empty\n  // Trim spaces, and filter out empty ones\n  var l = commaSeparatedFilters.split(',').map( function( item ) {\n    return item.replace(/ /g, '' );\n  }).filter( function( item ){\n    if( item === '' ) return false;\n    return true;\n  }).forEach( function( filterName ){\n    list.push( { type: 'filter', name: filterName, func: processing.filters[ filterName ] } );\n  });\n}\n\n\n\n// Make the array with the list of filters to be applied to the file\nvar makeFilterAndHookList = function( fileData, cb ){\n\n  var list = [];\n\n  // Make up defaults, empty if needed\n  var preProcessFilters = fileData.info.preProcessFilters || '';\n  var preFilters = fileData.info.preFilters || '';\n  var filters = fileData.info.filters || '';\n  var postFilters = fileData.info.postFilters || '';\n  var postProcessFilters = fileData.info.postProcessFilters || '';\n\n  // preProcessFilters and surrounding hooks\n  //addHooksToList( list, 'beforePreProcessFilters' );\n  vlog( \"preProcessFilters...\" ); addFiltersToList( list, preProcessFilters );\n  vlog( \"afterProcessFilters...\" ); addHooksToList( list, 'afterPreProcessFilters' );\n\n  // pre,-,post filters and surrounding hooks\n  vlog( \"beforeFilters...\" ); addHooksToList( list, 'beforeFilters' );\n  vlog( \"preFilters...\" ); addFiltersToList( list, preFilters );\n  vlog( \"filters...\" ); addFiltersToList( list, filters );\n  vlog( \"postFilters...\" ); addFiltersToList( list, postFilters );\n  vlog( \"afterFilters...\" ); addHooksToList( list, 'afterFilters' );\n\n  // When `fileData.info.delayPostProcess` is `true`, processing will stop here\n\n  // postProcessFilters and surrounding hooks\n  vlog( \"beforePostProcessFilters...\" ); addHooksToList( list, 'beforePostProcessFilters' );\n  vlog( \"postProcessFilters...\" ); addFiltersToList( list, postProcessFilters );\n  vlog( \"afterPostProcessFilters...\" ); addHooksToList( list, 'afterPostProcessFilters' );\n  vlog( \"afterEverything...\" ); addHooksToList( list, 'afterEverything' );\n\n  vlog(\"FINAL hook/filter list:\" );\n  vlog( list );\n  return cb( null, list );\n}\n\n\n// Public module methods\n\n\n// Getters and setters for 'processing' variables\n\nvar getConfig = exports.getConfig = function(){\n  return processing.config;\n}\n\nvar setConfig = exports.setConfig = function( config ){\n\n  config.ignoreHash = {};\n  config.copyHash = {};\n  config.smartCopyHash = {};\n  config.asFile = {};\n  config.linkAsFileHash = {};\n  config.linkAsDirectoryHash = {};\n\n  if( Array.isArray( config.ignore ) ){\n    config.ignore.forEach( function( ignore ){\n      config.ignoreHash[ deleteTrailingSlash( ignore ) ] = true;\n    });\n  }\n\n  if( Array.isArray( config.copy ) ){\n    config.copy.forEach( function( copy ){\n      config.copyHash[ deleteTrailingSlash( copy ) ] = true;\n    });\n  }\n\n  // #DOCUMENT\n  if( Array.isArray( config.smartCopy ) ){\n    config.smartCopy.forEach( function( smartCopy ){\n      config.smartCopyHash[ deleteTrailingSlash( smartCopy ) ] = true;\n    });\n  }\n\n\n  if( Array.isArray( config.linkAsFile ) ){\n    config.linkAsFile.forEach( function( linkAsFile ){\n      config.linkAsFileHash[ deleteTrailingSlash( linkAsFile ) ] = true;\n    });\n  }\n\n  if( Array.isArray( config.linkAsDirectory ) ){\n    config.linkAsDirectory.forEach( function( linkAsDirectory ){\n      config.linkAsDirectoryHash[ deleteTrailingSlash( linkAsDirectory ) ] = true;\n    });\n  }\n\n  processing.config = config;\n}\n\nvar getMainInfo = exports.getMainInfo = function(){\n  return processing.mainInfo;\n}\n\nvar setMainInfo = exports.setMainInfo = function( mainInfo ){\n  processing.mainInfo = mainInfo;\n}\n\nvar setVerbose = exports.setVerbose = function( verbose ){\n  processing.verbose = verbose;\n}\n\nvar getSrc = exports.getSrc = function(){\n    return processing.src;\n}\n\nvar setSrc = exports.setSrc = function( src ){\n  processing.src = deleteTrailingSlash( src );\n}\n\nvar getDst = exports.getDst = function(){\n  return processing.dst;\n}\n\nvar setDst = exports.setDst = function( dst ){\n  processing.dst = deleteTrailingSlash( dst );\n}\n\nvar getFilters = exports.getFilters = function(){\n  return processing.filters;\n}\n\nvar getYamlCache = exports.getYamlCache = function(){\n  return processing.yamlCache;\n}\n\nvar getWatch = exports.getWatch = function(){\n  return processing.watch;\n}\n\nvar setWatch = exports.setWatch = function( watch ){\n  processing.watch = watch;\n}\n\n\n\nvar yamlURLsFromPath = exports.yamlURLsFromPath = function( filePath ){\n  var l = filePath.split( p.sep );\n  var r = [];\n  var prec = '';\n\n  if( l[ 0 ] != '' ) l.unshift( '' );\n\n  // Make up the r array\n  l.forEach( function( e ){\n    prec = p.join( prec, e );\n    r.push( p.join( prec, '_info.yaml' ) );\n  });\n\n  // Return it\n  return r;\n}\n\n\nvar yamlFromFileURL = exports.yamlFromFileURL = function( originFileURL ){\n\n  var yamlFiles = yamlURLsFromPath( p.dirname( originFileURL ) );\n  var yamlCache = processing.yamlCache;\n\n  log(\"Processing origin file: \", originFileURL );\n\n  var finalYaml = {};\n  yamlFiles.forEach( function( yamlFile ){\n    if( yamlCache[ yamlFile ] ) enrichObject( finalYaml, yamlCache[ yamlFile ] );\n  });\n\n  vlog(\"Final YAML file to be applied:\", finalYaml );\n\n  return finalYaml;\n\n}\n\n\nvar callAllDone = exports.callAllDone = function( cb ){\n\n  log();\n  log(\"**************************************\");\n  log(\"**** ALL DONE HOOKS ******************\");\n  log(\"**************************************\");\n  log();\n\n  async.eachSeries(\n\n    processing.filterHooks.allDone,\n\n    function( item, cb ){\n\n      log( \"Executing allDone function: \", item.name );\n      item.executor.call( this, cb );\n    },\n\n    function( err ){\n      if( err ) return cb( err );\n      cb( null );\n    }\n\n  );\n}\n\nvar getFileType = exports.getFileType = function( filePath, fileNameAndExt, cb ){\n\n  var fullFilePath = p.join( getSrc(), filePath, fileNameAndExt );\n  fs.lstat( fullFilePath, function( err, fileStat ){\n    if( err ) return cb( err );\n\n    // Ryver is only interested in files, directories and symlinks. Anything else\n    // won't be dealt with (as it shouldn't)\n    var fileType;\n    if( fileStat.isFile() ) fileType= 'file';\n    else if( fileStat.isDirectory() ) fileType = 'directory';\n    else if( fileStat.isSymbolicLink() ) fileType = 'symlink';\n    else fileType = 'other';\n\n    // If it's not a symlink, we are totally done\n    if( fileType != 'symlink' ){\n      return cb( null, fileType, fileStat );\n    }\n\n    // If it IS a symlink, it will enrich fileStat with the location where the link points to\n    fs.readlink( fullFilePath, function( err, pointsTo ){\n      if( err ) return cb( err );\n\n      fileStat.pointsTo = pointsTo;\n      return cb( null, fileType, fileStat );\n    })\n  });\n}\n\n\n// Normal logging: log with levels 1 and 2\nvar log = exports.log = function( ){\n  if( processing.verbose == 1 || processing.verbose == 2 ){\n    console.log.apply( this, arguments );\n  }\n}\n\n// Very verbose logging: only log with level 2\nvar vlog = exports.vlog = function( ){\n\n  if( processing.verbose == 2 ){\n    if( typeof arguments[ 0 ] === 'function' && arguments.length == 1 ){\n      arguments[0].call( this );\n    } else {\n      console.log.apply( this, arguments );\n    }\n  }\n\n}\n\n// Read file, but trying with a backup path if the \"main\" one isn't there.\nvar readFile = exports.readFile = function( filePath, backupFilePath, fileNameAndExt, cb ){\n\n  var usedBackup = false;\n  var fileContentsAsBuffer;\n\n  // Load the contents of the landing file\n  fs.readFile( p.join( getSrc(), filePath, fileNameAndExt ), function( err, c ){\n    if( err && err.code !== 'ENOENT' ) return cb( err );\n\n    if( err && err.code == 'ENOENT' ){\n\n      // No backup: return the error as it was\n      if( ! backupFilePath ) return cb( err );\n\n      usedBackup = true;\n      fs.readFile( p.join( getSrc(), backupFilePath, fileNameAndExt ), function( err, c ){\n        if( err ) return cb( err );\n\n        fileContentsAsBuffer = c;\n        usedBackup = true;\n        restOfFunction();\n      });\n\n    } else {\n      fileContentsAsBuffer = c;\n      restOfFunction();\n    }\n\n    function restOfFunction(){\n      // At this point, usedBackup and fileContentsAsBuffer\n      // are all set and good\n\n      cb( null, fileContentsAsBuffer, usedBackup );\n    }\n  });\n}\n\n\nvar trimFileData = exports.trimFileData = function( fileData ){\n\n  var newFileData = cloneObject( fileData );\n\n  newFileData.initialContents = '';\n\n  if( newFileData.system.mimetype.split('/')[0] !== 'text'){\n    newFileData.contents = \"NON TEXT\";\n  }\n  newFileData.system.fileContentsAsBuffer = '';\n\n  return newFileData;\n}\n\n\n// http://stackoverflow.com/a/728694/829771\nvar cloneObject = exports.cloneObject = function( obj ) {\n\n    // Handle the 3 simple types, and null or undefined\n    if (null == obj || \"object\" != typeof obj) return obj;\n\n    // Handle Date\n    if (obj instanceof Date) {\n        var copy = new Date();\n        copy.setTime(obj.getTime());\n        return copy;\n    }\n\n    // Handle Array\n    if (obj instanceof Array) {\n        var copy = [];\n        for (var i = 0, len = obj.length; i < len; i++) {\n            copy[i] = cloneObject(obj[i]);\n        }\n        return copy;\n    }\n\n    if (obj instanceof Object) {\n    // Handle Object\n        var copy = {};\n        for (var attr in obj) {\n            if (obj.hasOwnProperty(attr)) copy[attr] = cloneObject(obj[attr]);\n        }\n        return copy;\n    }\n\n    throw new Error(\"Unable to copy obj! Its type isn't supported.\");\n}\n\n\n// Enrich an object using DeepObject\nvar enrichObject = exports.enrichObject = function( b, o ){\n  var deepObj = new DO( b );\n  for( var k in o ){\n    deepObj.set( k, o[ k ] );\n  }\n}\n\n// Set an object's value saving historical values in property + '_history'\nvar setSystemData = exports.setSystemData = function( system, key, value ) {\n  system[ key + '_history' ] = system[ key + '_history' ] || [];\n  system[ key + '_history' ].push( system[ key ] );\n  system[ key ] = value;\n}\n\n// Pre-collect all filters and hooks and store them in processing.filterHooks\n// and processing.filters, so that they are readily available when needed\n// (without re-emitting etc.)\nvar collectFiltersAndHooks = exports.collectFiltersAndHooks = function( cb ){\n\n  log( \"Collecting filters\")\n  eventEC.emitCollect( 'filter', function( err, filters ){\n    if( err ) return cb( err );\n\n    filters.onlyResults().forEach( function( filter ) {\n      log( \"Filter found and made available:\", filter.name );\n      processing.filters[ filter.name ] = filter.executor;\n    });\n\n    log( \"Collecting filter hooks\")\n\n    processing.filterHooks = {}\n    async.eachSeries(\n      [\n        'beforePreProcessFilters',\n        // ...front matter...\n        'afterPreProcessFilters',\n\n        'beforeFilters',\n        'afterFilters',\n\n        'beforePostProcessFilters',\n        'afterPostProcessFilters',\n        'beforeDelayedPostProcess',\n        'afterDelayedPostProcess',\n        'afterEverything',\n        'allDone'\n      ],\n      function( item, cb ){\n        eventEC.emitCollect( item, function( err, itemResult ){\n        log( \"Collecting hooks for \", item );\n          if( err ) return cb( err );\n\n          processing.filterHooks[ item ] = itemResult.onlyResults();\n          log( \"Function added to the hook:\",  processing.filterHooks[ item ].length );\n          vlog( \"Functions added:\",  processing.filterHooks[ item ] );\n\n          cb( null );\n        });\n      },\n      function( err ){\n        if( err ) return cb( err );\n\n        cb( null );\n      }\n    );\n  });\n}\n\n\n// Apply filters and hooks to fileData\n// There are three things to remember and consider:\n// 1) hooks in `beforePreProcessFilters` need to be able to change filters in\n//    fileData.info. So, `beforePreProcessFilters` hooks are injected into the\n//    filters/hooks pipeline,  _before_ the pipeline is properly created\n// 2) If `system.stopFiltering` is set at any point, filtering will stop end of story\n// 3) If `system.delayPostProcess` is set, processing will stop at\n//    `beforePostProcessFilters` (unless `system.inDelayedPostProcess` is true)\nvar filter = exports.filter = function( fileData, cb){\n\n  // If filtering was stopped, there is no point in doing _anything_\n  if( fileData.system.stopFiltering ){\n    log( \"Filtering stopped because of stopFiltering\" );\n    return cb( null );\n  }\n\n  // If the pipeline is already there, simply go through it\n  // This is used when this function is run in delayedPostProcess\n  if( fileData.filtersPipeline ){\n    goThroughPipeline();\n  } else {\n\n    // First of all, add the `beforePreProcessFilters` to the pipeline\n    // and filter file with *that*\n    fileData.filtersPipeline = [];\n    addHooksToList( fileData.filtersPipeline, 'beforePreProcessFilters' );\n\n    // At this point, the beforePreProcessFilters, which might change\n    // the filter attributes in fileData, is set\n    filter( fileData, function( err ){\n      if( err === 'stopped' ) return cb( 'stopped' );\n      if( err ) return cb( err );\n\n      // At this point, it will add more entries to the pipeline (which\n      // won't include beforePreProcessFlters) and will go through it\n      makeFilterAndHookList( fileData, function( err, r ){\n        if( err ) return cb( err );\n\n        fileData.filtersPipeline = r;\n        goThroughPipeline();\n      });\n    });\n  }\n\n  function goThroughPipeline(){\n\n    log( \"Putting file through filters and hooks now...\" );\n    vlog( fileData.filtersPipeline );\n\n    async.whilst(\n\n      function() { return fileData.filtersPipeline.length; },\n\n      function( cb ) {\n\n        // Convenience\n        var list = fileData.filtersPipeline;\n\n        // If the next element is the `beforePostProcessFilters` hook AND\n        // system.delayPostProcess is true AND system.inDelayedPostProcess if false,\n        // then it's time to quit -- even before getting the element out\n        if( list[ 0 ].type == 'hook' && list[ 0 ].hookName == 'beforePostProcessFilters' ){\n          if( fileData.system.delayPostProcess || fileData.info.delayPostProcess ){\n\n            if( ! fileData.system.inDelayedPostProcess ){\n              log(\"Postprocessing should be delayed, stopping here (for now)\");\n\n              // Adding extra hooks to the process pipelinee\n              addHooksToList( list, 'beforeDelayedPostProcess', true );\n\n              addHooksToList( list, 'afterDelayedPostProcess' );\n\n              // Adding file to the list of files that will need to be\n              // processed later\n              processing.toPostProcess.push( fileData );\n\n              // This will ensure that the `delayPostProcess` flag won't work next time\n              fileData.system.inDelayedPostProcess = true;\n\n              log(\"Hook/filter list (will be executed later):\" );\n              log( list );\n\n              return cb( 'delayed' );\n            } else {\n              log(\"Postprocessing was delayed and was resumed, continuing\");\n            }\n          } else {\n            log( \"postProcessing wasn't delayed, about to start it.\");\n          }\n        }\n\n        var item = list.shift();\n\n        if( item.name == 'dummy' )\n          log (\"Faking applying \", item.name, item.hookName );\n        else\n          log( \"\\n.........Applying \" + item.type + \":\", item.name );\n\n        if( item.type === 'filter' ){\n\n          // The filter must be defined\n          if( ! item.func  ) return cb( new Error(\"Filter \" + item.name + \" invalid!\") );\n\n          // Check that the filter hasn't already been applied\n          if( fileData.system.processedBy.indexOf( item.name ) != -1 ){\n            log( \"Filter was already applied:\", item.name );\n            return cb( null );\n          }\n        }\n\n        item.func.call( this, fileData, function( err ){\n          if( err ) return cb( err );\n\n          if( item.name != 'dummy')\n            vlog( function(){\n              vlog( \"fileData after \" + item.type + \" is:\", trimFileData( fileData ) );\n            } );\n\n          // Add the filter to the `processedBy` list, which is a nice log and\n          // it's used to avoid double-filtering\n          if( item.type == 'filter' ) fileData.system.processedBy.push( item.name );\n\n          // Check if the cycle should be interrupted\n          if( fileData.system.stopFiltering ) return cb( 'stopped' );\n\n          cb( null );\n        });\n\n      },\n      function ( err ) {\n        // If the cycle was stopped or delayed, simply\n        if( err === 'stopped' || err === 'delayed') return cb( null );\n\n        if( err ) return cb( err );\n\n        cb( null );\n      }\n    );\n  }\n}\n\n\n// Apply filter postProcess to items in processing.toPostProcess\n// (their processing was halted at the hook `afterFilter` because\n// `delayPostProcess` was set to `true`).\nvar filterDelayedItems = exports.filterDelayedItems = function( cb ){\n\n  if( processing.toPostProcess.length !== 0 )\n    log( \"There are some files that had delayPostProcess set to true. Processing them now\" );\n\n  async.eachSeries(\n    processing.toPostProcess,\n\n    function( fileData, cb ){\n      log( \"\\n\\n-------------------\\nPROCESSING \", fileData.system.fileName + fileData.system.fileExt,\"\\n-------------------\\n\" );\n      filter( fileData, function( err ){\n        if( err ) return cb( err );\n\n        cb( null );\n      });\n    },\n\n    function( err ){\n      if( err == 'stopped' ) return cb( null );\n      if( err ) return cb( err );\n\n      // Zap toPostProcess now that everything has been post-processed\n      processing.toPostProcess = [];\n\n      return cb( null );\n    }\n  );\n}\n\n// Make a fileData object. If fileContentsAsBuffer isn't set, it will\n// load it from filePath + fileName + fileExt\nvar makeFileData = exports.makeFileData = function( sourceURL, filePath, fileNameAndExt, fileContentsAsBuffer, info, skipCloning, cb ){\n\n  if( fileContentsAsBuffer ){\n    restOfFunction();\n  } else {\n    // TODO: Check if it's a symlink\n    fs.readFile( p.join( getSrc(), filePath, fileNameAndExt ), function( err, fr ){\n      if( err ) return cb( err );\n      fileContentsAsBuffer = fr;\n      restOfFunction();\n    });\n  }\n\n  function restOfFunction(){\n\n    magic.detect( fileContentsAsBuffer, function( err, magic ){\n      if( err ) return cb( err );\n\n      var fileExt = p.extname( fileNameAndExt );\n      var fileName = p.basename( fileNameAndExt, fileExt );\n\n      log(\"fileNameAndExt is\", fileNameAndExt, \"and as a result fileName is \", fileName, \"and fileExt is:\", fileExt );\n\n      //console.log(\"\\n\\n\\nINFO IS: \", require('util').inspect(info, {showHidden: false, depth: null}));\n      // Sets the basic file info\n      var fileData = {\n        system: {\n          filePath: filePath,\n          fileName: fileName,\n          fileExt: fileExt,\n          fileContentsAsBuffer: fileContentsAsBuffer,\n\n          mimetype: magic,\n          processedBy: [],\n          originDependencies: [],\n          originMasterFileURL: sourceURL ?  sourceURL : null,\n        },\n        initialInfo: skipCloning ? info : cloneObject( info ),\n        info: skipCloning ? info : cloneObject( info ),\n        initialContents: fileContentsAsBuffer,\n        contents: fileContentsAsBuffer,\n      };\n\n      // Convert to string if it's text-based mime type\n      // This will leave binary data (images, etc.) intact\n      if( fileData.system.mimetype.split('/')[0] === 'text')\n        fileData.contents = fileData.contents.toString('utf-8');\n\n      // Add all of the info files to originDependencies\n      yamlURLsFromPath( fileData.system.filePath ).forEach( function( URL ){\n        fileData.system.originDependencies.push( URL );\n      });\n\n\n      cb( null, fileData );\n    });\n  }\n}\n\n// Read and parse config file\nvar readYamlFile = exports.readYamlFile = function( baseObject, filePath, fileNameAndExt, cb ){\n\n  // Try and read the master _info.yaml file\n  fs.readFile( p.join( getSrc(), filePath, fileNameAndExt), function( err, yamlFileAsBuffer ){\n    if( err && err.code !== 'ENOENT' ) return cb( err );\n\n    // If the file wasn't find, then simply treat it as an empty result and\n    // return a copy of baseObject\n    if( err && err.code === 'ENOENT' ){\n      return cb( null, cloneObject( baseObject ) );\n    }\n\n    try {\n      var yamlData = yaml.safeLoad( yamlFileAsBuffer, { filename:  p.join( filePath, fileNameAndExt ) } );\n    } catch( err ) {\n      return cb( err );\n    }\n\n    // Add the raw yaml file it to the yamCache structure\n    if( fileNameAndExt === '_info.yaml' )\n      processing.yamlCache[ p.join( filePath, fileNameAndExt) ] = yamlData;\n\n    var newObject = cloneObject( baseObject );\n    enrichObject( newObject, yamlData );\n\n    cb( null, newObject, yamlData );\n  });\n}\n\n// Read and parse config file. It simply uses\nvar readAndSetConfig = exports.readAndSetConfig = function( cb ){\n\n  if( ! getSrc() ){\n    return cb( new Error(\"readAndSetConfig will only work after ryver.setSrc()\"));\n  }\n\n  readYamlFile( {}, '', '_config.yaml', function( err, data ){\n    if( err ) return cb( err );\n\n    setConfig( data );\n    return cb( null, data );\n  });\n}\n\n// Main \"build\" function that will recursively go through\n// absFilePath and filter each encountered file. It will also run\n// `filterDelayedItems()` once all files have been filtered\nvar build = exports.build = function( absFilePath, passedInfo, cb ){\n\n  // This function only works if process.src and process.dst are set\n  if( getSrc() === null )\n    return cb( new Error(\"You must set the source directory first with ryver.setSrc()\"));\n  if( getDst() === null )\n    return cb( new Error(\"You must set the destination directory first with ryver.setDst()\"));\n\n  var mainCycle = false;\n\n  // If the API signature `build( cb )` is used (no parameters),\n  // then set the initial parameters.\n  // Subsequent calls to this function will use the recursive signature\n  // build( absFilePath, passedInfo )\n\n  if( typeof absFilePath === 'function' ){\n    cb = absFilePath;\n    absFilePath = getSrc();\n    passedInfo = {};\n    mainCycle = true;\n  }\n\n  var info;\n  var filePath = absFilePath.substr( getSrc().length + 1 );\n\n  log( \"absFilePath (full fs path):\", absFilePath );\n  log( \"filePath (relative to getSrc():\", filePath );\n\n\n  console.log(\"Processing:\", absFilePath );\n\n  // Check if it needs to be ignored or copied (check if config file says so)\n  // #DOCUMENT\n  if( processing.config.ignoreHash[ filePath ] ){\n    log( \"File is to be ignored, ignoring\" );\n    return cb( null );\n  }\n\n\n\n  // Check if it needs to be ignored or copied (check if config file says so)\n  // #DOCUMENT\n  if( processing.config.copyHash[ filePath ] ){\n    log( \"File is to be copied straight through. Doing it\" );\n\n    fs.mkdirp( p.join( getDst(), filePath), function( err ){\n      if( err ) return cb( null );\n\n      fs.copy(  p.join( absFilePath ), p.join( getDst(), filePath  ), { clobber: true, preserveTimestamps: true }, function( err ){\n        if( err ) return cb( err );\n        return cb( null );\n      });\n    });\n\n  } else {\n\n    // Read all of the files in that directory\n    fs.readdir( absFilePath, function( err, fileNamesAndExt ){\n      if( err ) return cb( err );\n\n      log( \"Will process the following files:\", fileNamesAndExt );\n      vlog( \"Info (including inherited values) is:\", passedInfo );\n\n      // There is a _info.yaml in the local directory! It will load it, and\n      // make an info object based on passedInfo enriched with localInfo\n      if( fileNamesAndExt.indexOf( '_info.yaml' ) !== -1 ){\n\n        log( \"File _info.yaml found, reading it and enriching fileInfo with it\");\n\n        readYamlFile( passedInfo, filePath, '_info.yaml', function( err, loadedInfo ){\n          if( err ) return cb( err );\n\n          info = loadedInfo;\n          if( mainCycle ) setMainInfo( loadedInfo );\n          restOfFunction();\n        });\n      } else {\n        log( \"File _info.yaml not found, will use unchanged, inherited values\" );\n        info = passedInfo;\n        restOfFunction();\n      }\n\n      function restOfFunction(){\n\n        log( \"Going through all files in the directory\" );\n        async.eachSeries(\n          fileNamesAndExt,\n          function( fileNameAndExt, cb ){\n\n            log( \"\\n\\n-------------------\\nPROCESSING \", fileNameAndExt ,\"\\n-------------------\\n\" );\n            if( fileNameAndExt[ 0 ] === '_' ){\n              log( \"File starts with underscore, ignoring altogether\" );\n              return cb( null );\n            }\n\n            // Break up fileName into fileName and fileExt\n            //var fileExt = p.extname( fileNameAndExt );\n            //var fileName = p.basename( fileNameAndExt, fileExt );\n\n\n            getFileType( filePath, fileNameAndExt, function( err, fileType, statInfo ){\n              if( err ) return cb( err );\n\n              if( fileType == 'symlink' ){\n\n                log( \"Checking\", p.join( filePath, fileNameAndExt), 'against', processing.config.linkAsDirectoryHash, processing.config.linkAsFileHash );\n\n                if( processing.config.linkAsDirectoryHash[ p.join( filePath, fileNameAndExt)] ){\n                  log(\"File is symlink, but it will be treated as a directory as requested by config file\");\n                  fileType = 'directory';\n                }\n\n                if( processing.config.linkAsFileHash[ p.join( filePath, fileNameAndExt)] ){\n                  log(\"File is symlink, but it will be treated as a file as requested by config file\");\n                  fileType = 'file';\n                }\n\n              }\n\n              // If it's a directory, process it as such\n              if( fileType == 'directory' ){\n                log( \"File is a directory. Entering it, and processing files in there\" );\n                return build( p.join( getSrc(), filePath, fileNameAndExt ), info, cb );\n              }\n\n              // If it's a directory, process it as such\n              else if( fileType == 'symlink' ){\n                log( \"File is a symlink. Copying it straight\" );\n\n                // Delete link first. Unlike files, links are not just overwritten\n                fs.unlink( p.join( getDst(), filePath, fileNameAndExt  ), function( err ){\n                  if( err && err.code != 'ENOENT' ) return cb( err ); // ENOENT is allowed, it's just an attempt\n\n                    fs.mkdirp( p.join( getDst(), filePath ), function( err ){\n                      if( err ) return cb( err );\n\n                      fs.symlink(  statInfo.pointsTo, p.join( getDst(), filePath, fileNameAndExt  ),function( err ){\n\n                      //if( err ) return cb( err );\n                      if( err ) console.log(\"ERR DURING symlink:\", err );\n                      // Errors need to be quiet because the target might not yet exist\n                      // TODO: Fix this, make it so that symlinks to be made are added to an array and created\n                      // at the end\n\n\n                      return cb( null );\n                    });\n                  });\n                });\n              }\n\n              else if( fileType == 'other' ){\n                log( \"File is not a directory, a normal file or a symbolic link. Aborting.\" );\n                return cb( new Error( \"Error processing\", fileNameAndExt,\" in \", absFilePath, \" -- file needs to be a normal file, a directory or a symlink\"));\n              }\n\n              else {\n\n                log( \"It is a file. Reading its contents\" );\n\n                log( \"filePath: \", filePath );\n                log( \"getSrc() is: \", getSrc() );\n\n                // DETOUR: Check if its extension is in smartCopyHash,\n                // and if it is, skip it)\n                var ext = p.extname( fileNameAndExt );\n                if( processing.config.smartCopyHash[ ext ] ){\n                  // TODO: check file size, if size the same, do not copy\n                  log( \"File matches smartCopy extensione\", filePath, fileNameAndExt );\n\n                  var $s =  p.join( getSrc(), filePath, fileNameAndExt );\n                  var $d =  p.join( getDst(), filePath, fileNameAndExt );\n\n                  fs.stat( $s, function( err, $ss ){\n                    //if( err ) return cb( err );\n\n                    fs.stat( $d, function( err, $ds) {\n                      //if( err ) return cb( err );\n\n                      log( \"Comparing size of\", $s, $d, ($ss && $ss.size) || '[EMPTY]', ($ds && $ds.size) || '[EMPTY]' );\n                      if( $ss && $ds && $ss.size == $ds.size ){\n                        log(\"Same sizes! Skipping copying over...\");\n                        return cb( null );\n                      } else {\n                        log(\"Different sizes! Copying over...\");\n\n                        fs.mkdirp( p.join( getDst(), filePath ), function( err ){\n                          if( err ) return cb( err );\n\n                          fs.copy( $s, $d, { clobber: true, preserveTimestamps: true }, function( err ){\n                            if( err ) return cb( err );\n\n                            cb( null );\n\n                          });\n                        });\n\n                      }\n                    });\n\n                  });\n\n                } else {\n\n                  makeFileData( p.join( filePath, fileNameAndExt ), filePath, fileNameAndExt, null, info, false, function( err, fileData ){\n                    if( err ) return cb( err );\n\n                    // Add the file itself to the list of origins since it IS a file on the file system\n                    //fileData.system.originDependencies.push( p.join( filePath, fileNameAndExt ) );\n\n                    log( \"Basic fileData created\" );\n                    vlog( function(){\n                      vlog( \"Initial fileData before any filtering: \", trimFileData( fileData ) );\n                    });\n\n                    log( \"The file's mime type is \", fileData.system.mimetype );\n\n                    filter( fileData, function( err ){\n                      if( err ) return cb( err );\n\n                      vlog( function(){\n                        vlog( \"fileData after filtering: \", trimFileData( fileData ) );\n                      });\n\n\n                      cb( null );\n                    })\n                  })\n                }\n              }\n            })\n          },\n\n          function( err ){\n            if( err ) return cb( err );\n\n            if( ! mainCycle ) return cb( null );\n\n            log( \"\" );\n            log( \"*********************************************************************\" );\n            log( \"******** THE END -- NOW FILTERING DELAYED ITEMS *********************\" );\n            log( \"*********************************************************************\" );\n            log( \"\" );\n\n            // At this point, we ought to process all the items that reused to get processed\n            // and are now in processing.toPostProcess\n            filterDelayedItems( function( err ){\n              if( err ) return cb( err );\n\n              callAllDone( function( err ){\n                if( err ) return cb( err );\n\n                cb( null );\n              });\n\n            })\n          }\n        ); // End of async cycle\n      }\n    })\n  }\n}\n"]}