Comparing version 3.0.3 to 3.0.4
@@ -371,2 +371,4 @@ var util = require('./util') | ||
expand(obj, key, path.join(rootPath, acc.join('/')), expandDone) | ||
} else if (obj[key] === false) { | ||
delete obj[key] | ||
} | ||
@@ -373,0 +375,0 @@ acc.pop() |
{ | ||
"name": "vigour-fs", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "node's `fs` module with sugar on top + native support.", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "gaston test node" | ||
"test": "gaston test" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -1,109 +0,109 @@ | ||
var path = require('path') | ||
var fs = require('../../../lib/server') | ||
describe('cpr', function () { | ||
var srcDirPath = path.join(__dirname, 'dir') | ||
var srcOnePath = path.join(srcDirPath, 'one.txt') | ||
var srcTwoPath = path.join(srcDirPath, 'two.txt') | ||
var srcOneContent = 'Super witty remark' | ||
var srcTwoContent = 'Incredibly different' | ||
var dstDirPath = path.join(__dirname, 'dst') | ||
var dstOnePath = path.join(dstDirPath, 'one.txt') | ||
var dstTwoPath = path.join(dstDirPath, 'two.txt') | ||
before(function (done) { | ||
fs.writeFile(srcOnePath, srcOneContent, { encoding: 'utf8', mkdirp: true }, function (err) { | ||
if (err) { | ||
console.error('Error writing source file 1', err) | ||
} else { | ||
fs.writeFile(srcTwoPath, srcTwoContent, { encoding: 'utf8', mkdirp: true }, function (err) { | ||
if (err) { | ||
console.error('Error writing source file 2', err) | ||
} else { | ||
done() | ||
} | ||
}) | ||
} | ||
}) | ||
}) | ||
after(function (done) { | ||
fs.remove(srcDirPath, function (err) { | ||
if (err) { | ||
console.error('Error removing source directory', err) | ||
} else { | ||
done() | ||
} | ||
}) | ||
}) | ||
it('should copy directory', function (done) { | ||
fs.cpr(srcDirPath, dstDirPath, function (err) { | ||
expect(err).not.to.exist | ||
var one | ||
var two | ||
fs.readFile(dstOnePath, 'utf8', function (err, content) { | ||
expect(err).not.to.exist | ||
expect(content).to.equal(srcOneContent) | ||
one = true | ||
finish() | ||
}) | ||
fs.readFile(dstTwoPath, 'utf8', function (err, content) { | ||
expect(err).not.to.exist | ||
expect(content).to.equal(srcTwoContent) | ||
two = true | ||
finish() | ||
}) | ||
function finish () { | ||
if (one && two) { | ||
done() | ||
} | ||
} | ||
}) | ||
after(function (done) { | ||
fs.remove(dstDirPath, function (err) { | ||
if (err) { | ||
console.error('Error removing destination directory', err) | ||
} else { | ||
done() | ||
} | ||
}) | ||
}) | ||
}) | ||
it('should create missing directories', function (done) { | ||
var dstDirBase = path.join(__dirname, 'newDir') | ||
var dstDirPath = path.join(dstDirBase, 'dst') | ||
var dstOnePath = path.join(dstDirPath, 'one.txt') | ||
var dstTwoPath = path.join(dstDirPath, 'two.txt') | ||
fs.cpr(srcDirPath, dstDirPath, function (err) { | ||
expect(err).not.to.exist | ||
var one | ||
var two | ||
fs.readFile(dstOnePath, 'utf8', function (err, content) { | ||
expect(err).not.to.exist | ||
expect(content).to.equal(srcOneContent) | ||
one = true | ||
finish() | ||
}) | ||
fs.readFile(dstTwoPath, 'utf8', function (err, content) { | ||
expect(err).not.to.exist | ||
expect(content).to.equal(srcTwoContent) | ||
two = true | ||
finish() | ||
}) | ||
function finish () { | ||
if (one && two) { | ||
done() | ||
} | ||
} | ||
}) | ||
after(function (done) { | ||
fs.remove(dstDirBase, function (err) { | ||
if (err) { | ||
console.error('Error removing destination directory', err) | ||
} else { | ||
done() | ||
} | ||
}) | ||
}) | ||
}) | ||
}) | ||
// var path = require('path') | ||
// var fs = require('../../../lib/server') | ||
// | ||
// describe('cpr', function () { | ||
// var srcDirPath = path.join(__dirname, 'dir') | ||
// var srcOnePath = path.join(srcDirPath, 'one.txt') | ||
// var srcTwoPath = path.join(srcDirPath, 'two.txt') | ||
// var srcOneContent = 'Super witty remark' | ||
// var srcTwoContent = 'Incredibly different' | ||
// var dstDirPath = path.join(__dirname, 'dst') | ||
// var dstOnePath = path.join(dstDirPath, 'one.txt') | ||
// var dstTwoPath = path.join(dstDirPath, 'two.txt') | ||
// before(function (done) { | ||
// fs.writeFile(srcOnePath, srcOneContent, { encoding: 'utf8', mkdirp: true }, function (err) { | ||
// if (err) { | ||
// console.error('Error writing source file 1', err) | ||
// } else { | ||
// fs.writeFile(srcTwoPath, srcTwoContent, { encoding: 'utf8', mkdirp: true }, function (err) { | ||
// if (err) { | ||
// console.error('Error writing source file 2', err) | ||
// } else { | ||
// done() | ||
// } | ||
// }) | ||
// } | ||
// }) | ||
// }) | ||
// after(function (done) { | ||
// fs.remove(srcDirPath, function (err) { | ||
// if (err) { | ||
// console.error('Error removing source directory', err) | ||
// } else { | ||
// done() | ||
// } | ||
// }) | ||
// }) | ||
// | ||
// it('should copy directory', function (done) { | ||
// fs.cpr(srcDirPath, dstDirPath, function (err) { | ||
// expect(err).not.to.exist | ||
// var one | ||
// var two | ||
// fs.readFile(dstOnePath, 'utf8', function (err, content) { | ||
// expect(err).not.to.exist | ||
// expect(content).to.equal(srcOneContent) | ||
// one = true | ||
// finish() | ||
// }) | ||
// fs.readFile(dstTwoPath, 'utf8', function (err, content) { | ||
// expect(err).not.to.exist | ||
// expect(content).to.equal(srcTwoContent) | ||
// two = true | ||
// finish() | ||
// }) | ||
// function finish () { | ||
// if (one && two) { | ||
// done() | ||
// } | ||
// } | ||
// }) | ||
// after(function (done) { | ||
// fs.remove(dstDirPath, function (err) { | ||
// if (err) { | ||
// console.error('Error removing destination directory', err) | ||
// } else { | ||
// done() | ||
// } | ||
// }) | ||
// }) | ||
// }) | ||
// | ||
// it('should create missing directories', function (done) { | ||
// var dstDirBase = path.join(__dirname, 'newDir') | ||
// var dstDirPath = path.join(dstDirBase, 'dst') | ||
// var dstOnePath = path.join(dstDirPath, 'one.txt') | ||
// var dstTwoPath = path.join(dstDirPath, 'two.txt') | ||
// fs.cpr(srcDirPath, dstDirPath, function (err) { | ||
// expect(err).not.to.exist | ||
// var one | ||
// var two | ||
// fs.readFile(dstOnePath, 'utf8', function (err, content) { | ||
// expect(err).not.to.exist | ||
// expect(content).to.equal(srcOneContent) | ||
// one = true | ||
// finish() | ||
// }) | ||
// fs.readFile(dstTwoPath, 'utf8', function (err, content) { | ||
// expect(err).not.to.exist | ||
// expect(content).to.equal(srcTwoContent) | ||
// two = true | ||
// finish() | ||
// }) | ||
// function finish () { | ||
// if (one && two) { | ||
// done() | ||
// } | ||
// } | ||
// }) | ||
// after(function (done) { | ||
// fs.remove(dstDirBase, function (err) { | ||
// if (err) { | ||
// console.error('Error removing destination directory', err) | ||
// } else { | ||
// done() | ||
// } | ||
// }) | ||
// }) | ||
// }) | ||
// }) |
var path = require('path') | ||
var log = require('npmlog') | ||
var fs = require("../../../") | ||
var fs = require('../../../') | ||
var root = path.join(__dirname, '..', '..', 'data') | ||
describe("fs.expandStars", function () { | ||
var expected = | ||
{ a: | ||
{ "c.txt": true | ||
, "d.txt": true | ||
, "sub": | ||
{ "sub.txt": true } | ||
} | ||
, "b.txt": true | ||
, e: | ||
{ h: | ||
{ "i.txt": true } | ||
} | ||
} | ||
it("should return the expected object", function () { | ||
var obj = | ||
{ a: "*" | ||
, "b.txt": true | ||
, e: | ||
{ h: "*" } | ||
} | ||
return fs.expandStars(obj, root) | ||
.then(function (observed) { | ||
expect(observed).to.deep.equal(expected) | ||
}) | ||
}) | ||
it("should also work with `true` instead of `*`", function () { | ||
var obj = | ||
{ a: true | ||
, "b.txt": true | ||
, e: | ||
{ h: true } | ||
} | ||
return fs.expandStars(obj, root) | ||
.then(function (observed) { | ||
expect(observed).to.deep.equal(expected) | ||
}) | ||
}) | ||
}) | ||
describe('fs.expandStars', function () { | ||
var expected = { | ||
a: { | ||
'c.txt': true, | ||
'd.txt': true, | ||
'sub': { | ||
'sub.txt': true | ||
} | ||
}, | ||
'b.txt': true, | ||
e: { | ||
h: { 'i.txt': true } | ||
} | ||
} | ||
it('should return the expected object', function () { | ||
var obj = { | ||
a: '*', | ||
'b.txt': true, | ||
e: { h: '*' } | ||
} | ||
return fs.expandStars(obj, root) | ||
.then(function (observed) { | ||
expect(observed).to.deep.equal(expected) | ||
}) | ||
}) | ||
it('should also work with `true` instead of `*`', function () { | ||
var obj = { | ||
a: true, | ||
'b.txt': true, | ||
e: { h: true } | ||
} | ||
return fs.expandStars(obj, root) | ||
.then(function (observed) { | ||
expect(observed).to.deep.equal(expected) | ||
}) | ||
}) | ||
it('should also work with `false`', function () { | ||
var obj = { | ||
a: true, | ||
'b.txt': true, | ||
e: false | ||
} | ||
var myExpected = { | ||
a: { | ||
'c.txt': true, | ||
'd.txt': true, | ||
'sub': { | ||
'sub.txt': true | ||
} | ||
}, | ||
'b.txt': true | ||
} | ||
return fs.expandStars(obj, root) | ||
.then(function (observed) { | ||
console.log('ob', observed) | ||
expect(observed).to.deep.equal(myExpected) | ||
}) | ||
}) | ||
}) |
Sorry, the diff of this file is not supported yet
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7780655
2930
3