   error
 
 # Override fs APIs.
-statSync = fs.statSync
-fs.statSync = (p) ->
+lstatSync = fs.lstatSync
+fs.lstatSync = (p) ->
   [isAsar, asarPath, filePath] = splitPath p
-  return statSync p unless isAsar
+  return lstatSync p unless isAsar
 
   archive = asar.createArchive asarPath
   throw new Error("Invalid package #{asarPath}") unless archive


  asarStatsToFsStats stats

stat = fs.stat
fs.stat = (p, callback) ->
  [isAsar, asarPath, filePath] = splitPath p
  return stat p, callback unless isAsar

  archive = asar.createArchive asarPath
  return callback throw new Error("Invalid package #{asarPath}") unless archive

  return callback createNotFoundError(asarPath, filePath) unless stats

  callback undefined, asarStatsToFsStats stats

statSync = fs.statSync
fs.statSync = (p) ->
  [isAsar, asarPath, filePath] = splitPath p
  return statSync p unless isAsar

  # Do not distinguish links for now.
  fs.lstatSync p

stat = fs.stat
fs.stat = (p, callback) ->
  [isAsar, asarPath, filePath] = splitPath p
  return stat p, callback unless isAsar

  # Do not distinguish links for now.
  fs.lstat p, callback

statSyncNoException = fs.statSyncNoException
fs.statSyncNoException = (p) ->
