diff --git a/lib/copy/copy.js b/lib/copy/copy.js index 5add3ac8..1aa53228 100644 --- a/lib/copy/copy.js +++ b/lib/copy/copy.js @@ -1,7 +1,7 @@ 'use strict' const fs = require('graceful-fs') -const {resolve, join, dirname, basename, sep} = require('path') +const path = require('path') const mkdirp = require('../mkdirs').mkdirs const pathExists = require('../path-exists').pathExists const utimes = require('../util/utimes').utimesMillis @@ -29,13 +29,13 @@ function copy (src, dest, opts, cb) { see https://github.com/jprichardson/node-fs-extra/issues/269`) } - src = resolve(src) - dest = resolve(dest) + src = path.resolve(src) + dest = path.resolve(dest) // don't allow src and dest to be the same if (src === dest) return cb(new Error('Source and destination must not be the same.')) - const destParent = dirname(dest) + const destParent = path.dirname(dest) pathExists(destParent, (err, dirExists) => { if (err) return cb(err) if (dirExists) return startCopy(src, dest, opts, cb) @@ -166,7 +166,7 @@ function cpDir (src, dest, opts, cb) { function cpDirItems (items, src, dest, opts, cb) { const item = items.pop() if (!item) return cb() - startCopy(join(src, item), join(dest, item), opts, err => { + startCopy(path.join(src, item), path.join(dest, item), opts, err => { if (err) return cb(err) return cpDirItems(items, src, dest, opts, cb) }) @@ -177,7 +177,7 @@ function onLink (src, dest, opts, cb) { if (err) return cb(err) if (opts.dereference) { - resolvedSrcPath = resolve(process.cwd(), resolvedSrcPath) + resolvedSrcPath = path.resolve(process.cwd(), resolvedSrcPath) } checkDest(dest, (err, resolvedDestPath) => { @@ -189,7 +189,7 @@ function onLink (src, dest, opts, cb) { return fs.symlink(resolvedSrcPath, dest, cb) } else { if (opts.dereference) { - resolvedDestPath = resolve(process.cwd(), resolvedDestPath) + resolvedDestPath = path.resolve(process.cwd(), resolvedDestPath) } if (resolvedDestPath === resolvedSrcPath) return cb() @@ -233,11 +233,11 @@ function checkDest (dest, cb) { // return true if dest is a subdir of src, otherwise false. // extract dest base dir and check if that is the same as src basename function isSrcSubdir (src, dest) { - const baseDir = dest.split(dirname(src) + sep)[1] + const baseDir = dest.split(path.dirname(src) + path.sep)[1] if (baseDir) { - const destBasename = baseDir.split(sep)[0] + const destBasename = baseDir.split(path.sep)[0] if (destBasename) { - return src !== dest && dest.indexOf(src) > -1 && destBasename === basename(src) + return src !== dest && dest.indexOf(src) > -1 && destBasename === path.basename(src) } return false }