Comparing version 1.1.1 to 1.1.2
@@ -220,3 +220,3 @@ /* | ||
} | ||
/*istanbul ignore else - filtered should be an array, but just in case*/ | ||
@@ -308,3 +308,7 @@ if (filtered.length) { | ||
if (stat.isFile()) { | ||
return copyFile(options.from, path.join(to, path.basename(options.from)), options, callback); | ||
var dirRegex = new RegExp(path.sep + '$'); | ||
if (dirRegex.test(to)) { // Create directory if has trailing separator | ||
to = path.join(to, path.basename(options.from)); | ||
} | ||
return copyFile(options.from, to, options, callback); | ||
} | ||
@@ -311,0 +315,0 @@ callback(new Error('From should be a file or directory')); |
@@ -5,3 +5,3 @@ { | ||
"author": "Dav Glass <davglass@gmail.com>", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"dependencies": { | ||
@@ -8,0 +8,0 @@ "graceful-fs": "~4.1.2", |
@@ -13,3 +13,3 @@ var assert = require('assert'), | ||
this.timeout(55000); | ||
describe('loading', function() { | ||
@@ -19,7 +19,7 @@ before(function() { | ||
}); | ||
it('should export raw method', function () { | ||
assert.equal(typeof cpr, 'function'); | ||
}); | ||
it('should export cpr method too', function () { | ||
@@ -29,7 +29,7 @@ assert.equal(typeof cpr.cpr, 'function'); | ||
}); | ||
describe('should copy node_modules', function() { | ||
var out = path.join(to, '0'); | ||
var data = {}; | ||
before(function(done) { | ||
@@ -44,3 +44,3 @@ cpr(from, out, function(err, status) { | ||
}); | ||
it('has ./out/0', function() { | ||
@@ -70,3 +70,3 @@ var stat = fs.statSync(out); | ||
}); | ||
describe('should NOT copy node_modules', function() { | ||
@@ -89,3 +89,3 @@ var out = path.join(to, '1'), | ||
}); | ||
it('does not have ./out/1', function() { | ||
@@ -98,3 +98,3 @@ assert.ok(data.stat); // Should be an error | ||
}); | ||
}); | ||
@@ -122,3 +122,3 @@ | ||
}); | ||
it('returns files array with confirm', function() { | ||
@@ -191,3 +191,3 @@ assert.ok(Array.isArray(data.status)); | ||
}); | ||
}); | ||
@@ -234,3 +234,3 @@ | ||
}); | ||
}); | ||
@@ -283,7 +283,7 @@ | ||
}); | ||
}); | ||
describe('error handling', function() { | ||
it('should fail on non-existant from dir', function(done) { | ||
@@ -297,3 +297,3 @@ cpr('./does/not/exist', path.join(to, 'does/not/matter'), function(err, status) { | ||
}); | ||
it('should fail on non-file', function(done) { | ||
@@ -340,3 +340,3 @@ cpr('/dev/null', path.join(to, 'does/not/matter'), function(err, status) { | ||
describe('validations', function() { | ||
it('should copy empty directory', function(done) { | ||
@@ -350,3 +350,3 @@ mkdirp.sync(path.join(to, 'empty-src')); | ||
}); | ||
it('should not delete existing folders in out dir', function(done) { | ||
@@ -364,7 +364,7 @@ mkdirp.sync(path.join(to, 'empty-src', 'a')); | ||
}); | ||
it('should copy one file', function(done) { | ||
cpr(__filename, path.join(to, 'one-file-test/'), { overwrite: true }, function(err) { | ||
cpr(__filename, path.join(to, 'one-file-test.js'), { overwrite: true }, function(err) { | ||
assert.equal(undefined, err); | ||
var stat = fs.statSync(path.join(to, 'one-file-test/full.js')); | ||
var stat = fs.statSync(path.join(to, 'one-file-test.js')); | ||
assert.ok(stat.isFile()); | ||
@@ -375,4 +375,13 @@ done(); | ||
it('should copy one file in dir if to has trailing sep', function(done) { | ||
cpr(__filename, path.join(to, 'one-file-dir'+path.sep), { overwrite: true }, function(err) { | ||
assert.equal(undefined, err); | ||
var stat = fs.statSync(path.join(to, 'one-file-dir','full.js')); | ||
assert.ok(stat.isFile()); | ||
done(); | ||
}); | ||
}); | ||
it('should not copy because file exists', function(done) { | ||
cpr(__filename, path.join(to, 'one-file-test/'), function(err, status) { | ||
cpr(__filename, path.join(to, 'one-file-test.js'), function(err, status) { | ||
assert.equal(undefined, status); | ||
@@ -402,3 +411,3 @@ assert(err instanceof Error); | ||
}); | ||
it('has ./out/4', function() { | ||
@@ -423,5 +432,5 @@ var stat = fs.statSync(out); | ||
}); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46651
696