<commit_before>fs = require 'fs'
Module = require 'module'
path = require 'path'

_ = require 'underscore-plus'
async = require 'async'
CSON = null # Lazily require
mkdirp = require 'mkdirp'
plist = null # Lazily require
rimraf = require 'rimraf'

# Public: Useful extensions to node's built-in fs module
#
# Important, this extends Node's builtin in ['fs' module][fs], which means that you
# can do anything that you can do with Node's 'fs' module plus a few extra
# functions that we've found to be helpful.
#
# [fs]: http://nodejs.org/api/fs.html
fsPlus =
  getHomeDirectory: ->
    if process.platform is 'win32'
      process.env.USERPROFILE
    else
      process.env.HOME

  # Public: Make the given path absolute by resolving it against the current
  # working directory.
  #
  # * relativePath:
  #   The String containing the relative path. If the path is prefixed with
  #   '~', it will be expanded to the current user's home directory.
  #
  # Returns the absolute path or the relative path if it's unable to determine
  # it's realpath.
  absolute: (relativePath) ->
    return null unless relativePath?

    homeDir = fsPlus.getHomeDirectory()

    if relativePath is '~'
      relativePath = homeDir
    else if relativePath.indexOf('~/') is 0
      relativePath = "#{homeDir}#{relativePath.substring(1)}"

    try
      fs.realpathSync(relativePath)
    catch e
      relativePath

  # Public: Is the given path absolute?
  #
  # * pathToCheck:
  #   The relative or absolute path to check.
  #
  # Returns true if the path is absolute, false otherwise.
  isAbsolute: (pathToCheck='') ->
    if process.platform is 'win32'
      pathToCheck[1] is ':' # C:\ style
    else
      pathToCheck[0] is '/' # /usr style

  # Public: Returns true if a file or folder at the specified path exists.
  existsSync: (pathToCheck) ->
    pathToCheck? and statSyncNoException(pathToCheck) isnt false

  # Public: Returns true if the given path exists and is a directory.
  isDirectorySync: (directoryPath) ->
    return false unless directoryPath?.length > 0
    if stat = statSyncNoException(directoryPath)
      stat.isDirectory()
    else<commit_msg>Return false early for empty path<commit_after>fs = require 'fs'
Module = require 'module'
path = require 'path'

_ = require 'underscore-plus'
async = require 'async'
CSON = null # Lazily require
mkdirp = require 'mkdirp'
plist = null # Lazily require
rimraf = require 'rimraf'

# Public: Useful extensions to node's built-in fs module
#
# Important, this extends Node's builtin in ['fs' module][fs], which means that you
# can do anything that you can do with Node's 'fs' module plus a few extra
# functions that we've found to be helpful.
#
# [fs]: http://nodejs.org/api/fs.html
fsPlus =
  getHomeDirectory: ->
    if process.platform is 'win32'
      process.env.USERPROFILE
    else
      process.env.HOME

  # Public: Make the given path absolute by resolving it against the current
  # working directory.
  #
  # * relativePath:
  #   The String containing the relative path. If the path is prefixed with
  #   '~', it will be expanded to the current user's home directory.
  #
  # Returns the absolute path or the relative path if it's unable to determine
  # it's realpath.
  absolute: (relativePath) ->
    return null unless relativePath?

    homeDir = fsPlus.getHomeDirectory()

    if relativePath is '~'
      relativePath = homeDir
    else if relativePath.indexOf('~/') is 0
      relativePath = "#{homeDir}#{relativePath.substring(1)}"

    try
      fs.realpathSync(relativePath)
    catch e
      relativePath

  # Public: Is the given path absolute?
  #
  # * pathToCheck:
  #   The relative or absolute path to check.
  #
  # Returns true if the path is absolute, false otherwise.
  isAbsolute: (pathToCheck='') ->
    if process.platform is 'win32'
      pathToCheck[1] is ':' # C:\ style
    else
      pathToCheck[0] is '/' # /usr style

  # Public: Returns true if a file or folder at the specified path exists.
  existsSync: (pathToCheck) ->
    pathToCheck?.length > 0 and statSyncNoException(pathToCheck) isnt false

  # Public: Returns true if the given path exists and is a directory.
  isDirectorySync: (directoryPath) ->
    return false unless directoryPath?.length > 0
    if stat = statSyncNoException(directoryPath)
      stat.isDirectory()
    else
{'fraction_non_alphanumeric': 0.09260539046302695, 'fraction_numerical': 0.004376871688551025, 'mean_word_length': 3.294757665677547, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 16, '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': '722731', 'n_tokens_mistral': 1314, 'n_tokens_neox': 1264, 'n_words': 485}