<commit_before>path = require 'path'
glob = require('glob')
fs = require 'fs-extra'
async = require 'async'
parsePath = require 'parse-filepath'
_ = require 'underscore'

globPages = require './glob-pages'

module.exports = (program, cb) ->
  {relativeDirectory, directory} = program

  globPages directory, (err, pages) ->

    # Async callback to copy each file.
    copy = (file, callback) ->
      # Map file to path generated for that directory.
      # e.g. if file is in directory 2015-06-16-my-sweet-blog-post that got
      # rewritten to my-sweet-blog-post, we find that path rewrite so
      # our asset gets copied to the right directory.
      parsed = parsePath file
      relativePath = path.relative(directory + "/pages", file)
      oldPath = parsePath(relativePath).dirname

      # Wouldn't rewrite basePath
      if oldPath is "."
        oldPath = "/"
        newPath = "/#{parsed.basename}"

      unless oldPath is "/"
        page = _.find pages, (page) ->
          parsePath(page.requirePath).dirname is oldPath

        newPath = parsePath(page.path).dirname + parsed.basename

      newPath = directory + "/public/" + newPath
      fs.copy(file, newPath, (err) ->
        callback err
      )

    # Copy static assets to public folder.
    glob directory + '/pages/**/?(*.jpg|*.png|*.pdf)', null, (err, files) ->
      async.map files, copy, (err, results) ->
        cb(err, results)
<commit_msg>Add more static file types to be copied to public folder<commit_after>path = require 'path'
glob = require('glob')
fs = require 'fs-extra'
async = require 'async'
parsePath = require 'parse-filepath'
_ = require 'underscore'

globPages = require './glob-pages'

module.exports = (program, cb) ->
  {relativeDirectory, directory} = program

  globPages directory, (err, pages) ->

    # Async callback to copy each file.
    copy = (file, callback) ->
      # Map file to path generated for that directory.
      # e.g. if file is in directory 2015-06-16-my-sweet-blog-post that got
      # rewritten to my-sweet-blog-post, we find that path rewrite so
      # our asset gets copied to the right directory.
      parsed = parsePath file
      relativePath = path.relative(directory + "/pages", file)
      oldPath = parsePath(relativePath).dirname

      # Wouldn't rewrite basePath
      if oldPath is "."
        oldPath = "/"
        newPath = "/#{parsed.basename}"

      unless oldPath is "/"
        page = _.find pages, (page) ->
          parsePath(page.requirePath).dirname is oldPath

        newPath = parsePath(page.path).dirname + parsed.basename

      newPath = directory + "/public/" + newPath
      fs.copy(file, newPath, (err) ->
        callback err
      )

    # Copy static assets to public folder.
    glob directory + '/pages/**/?(*.jpg|*.png|*.pdf|*.gif|*.ico)', null, (err, files) ->
      async.map files, copy, (err, results) ->
        cb(err, results)

{'fraction_non_alphanumeric': 0.12659098727210183, 'fraction_numerical': 0.005503955968352253, 'mean_word_length': 2.612422360248447, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5600875', 'n_tokens_mistral': 877, 'n_tokens_neox': 840, 'n_words': 272}