var fs = require('graceful-fs')
var path = require('path')
var ncp = require('./ncp')
var mkdir = require('../mkdirs')

function copy (src, dest, options, callback) {
  if (typeof options === 'function' && !callback) {
    callback = options
    options = {}
  } else if (typeof options === 'function' || options instanceof RegExp) {
    options = {filter: options}
  }
  callback = callback || function () {}
  options = options || {}

  // Warn about using preserveTimestamps on 32-bit node:
  if (options.preserveTimestamps && process.arch === 'ia32') {
    console.warn('fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n' +
    'see https://github.com/jprichardson/node-fs-extra/issues/269')
  }

  // don't allow src and dest to be the same
  var basePath = process.cwd()
  var currentPath = path.resolve(basePath, src)
  var targetPath = path.resolve(basePath, dest)
  if (currentPath === targetPath) return callback(new Error('Source and destination must not be the same.'))

  fs.lstat(src, function (err, stats) {
    if (err) return callback(err)

    var dir = null
    if (stats.isDirectory()) {
      var parts = dest.split(path.sep)
      parts.pop()
      dir = parts.join(path.sep)
    } else {
      dir = path.dirname(dest)
    }

    fs.exists(dir, function (dirExists) {
      if (dirExists) return ncp(src, dest, options, callback)
      mkdir.mkdirs(dir, function (err) {
        if (err) return callback(err)
        ncp(src, dest, options, callback)
      })
    })
  })
}

module.exports = copy

@@ -1,11 +1,27 @@
-var
+'use strict'%0A%0Aconst
  fs = re
@@ -41,19 +41,21 @@
 ul-fs')%0A
-var
+const
  path = 
@@ -70,19 +70,21 @@
 'path')%0A
-var
+const
  ncp = r
@@ -99,19 +99,21 @@
 ./ncp')%0A
-var
+const
  mkdir =
@@ -589,17 +589,17 @@
 le.warn(
-'
+%60
 fs-extra
@@ -676,17 +676,13 @@
 d;%5Cn
-' +
 %0A    
-'
 see 
@@ -737,17 +737,17 @@
 sues/269
-'
+%60
 )%0A  %7D%0A%0A 
@@ -792,19 +792,21 @@
  same%0A  
-var
+const
  basePat
@@ -825,19 +825,21 @@
 cwd()%0A  
-var
+const
  current
@@ -875,19 +875,21 @@
  src)%0A  
-var
+const
  targetP
@@ -1048,25 +1048,16 @@
 tat(src,
- function
  (err, s
@@ -1061,16 +1061,19 @@
 , stats)
+ =%3E
  %7B%0A    i
@@ -1106,19 +1106,19 @@
 r)%0A%0A    
-var
+let
  dir = n
@@ -1162,11 +1162,13 @@
     
-var
+const
  par
@@ -1314,26 +1314,16 @@
 ts(dir, 
-function (
 dirExist
@@ -1323,17 +1323,19 @@
 irExists
-)
+ =%3E
  %7B%0A     
@@ -1419,22 +1419,14 @@
 ir, 
-function (err)
+err =%3E
  %7B%0A 

Refactor copy