Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fs-merger

Package Overview
Dependencies
Maintainers
3
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fs-merger - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

13

dist/index.js

@@ -53,4 +53,15 @@ "use strict";

let fullPath = relativePath;
let byPassAbsPathCheck = false;
switch (propertyName) {
case 'at':
byPassAbsPathCheck = true;
break;
case 'entries':
if (!relativePath) {
byPassAbsPathCheck = true;
}
break;
}
// at is a spcfical property exist in FSMerge which takes number as input do not perform path operation on it.
if (propertyName == 'at' || !path.isAbsolute(relativePath)) {
if (byPassAbsPathCheck || !path.isAbsolute(relativePath)) {
// if property is present in the FSMerge do not hijack it with fs operations

@@ -57,0 +68,0 @@ if (this[propertyName]) {

{
"name": "fs-merger",
"version": "3.0.2",
"version": "3.0.3",
"description": "Reads files from a real location",

@@ -15,2 +15,6 @@ "main": "dist/index.js",

},
"repository": {
"type": "git",
"url": "https://github.com/SparshithNR/fs-merger.git"
},
"devDependencies": {

@@ -17,0 +21,0 @@ "@types/node": "^12.11.5",

@@ -71,5 +71,17 @@ "use strict";

let fullPath = relativePath
let byPassAbsPathCheck = false;
switch (propertyName) {
case 'at':
byPassAbsPathCheck = true;
break;
case 'entries':
if (!relativePath) {
byPassAbsPathCheck = true;
}
break;
}
// at is a spcfical property exist in FSMerge which takes number as input do not perform path operation on it.
if (propertyName == 'at' || !path.isAbsolute(relativePath)) {
if (byPassAbsPathCheck || !path.isAbsolute(relativePath)) {
// if property is present in the FSMerge do not hijack it with fs operations

@@ -76,0 +88,0 @@ if (this[propertyName]) {

38

tests/unit-test.js

@@ -307,11 +307,33 @@ "use strict";

it('can read entries from fsMeger.fs as well', function () {
fsMerger = new FSMerge(['fixtures/test-1', 'fixtures/test-2', 'fixtures/test-3']).fs;
let fsEntries = fsMerger.entries('./');
let fileList = [];
let walkList = ['a.txt', 'b.txt', 'c.txt', 'd.txt', 'test-1/', 'test-1/b.txt', 'test-sub-1/', 'test-sub-1/sub-b.txt', 'test-sub-1/sub-c.txt', 'test-sub-1/test-sub-sub-1/', 'test-sub-1/test-sub-sub-1/sub-sub-b.txt', 'test-sub-1/test-sub-sub-1/sub-sub-c.txt', 'test-sub-2/' ,'x.txt'];
fsEntries.forEach(entry => {
fileList.push(entry.relativePath);
describe('can read entries from fsMeger.fs as well', function () {
it('take path as input', function() {
fsMerger = new FSMerge(['fixtures/test-1', 'fixtures/test-2', 'fixtures/test-3']).fs;
let fsEntries = fsMerger.entries('./');
let fileList = [];
let walkList = ['a.txt', 'b.txt', 'c.txt', 'd.txt', 'test-1/', 'test-1/b.txt', 'test-sub-1/', 'test-sub-1/sub-b.txt', 'test-sub-1/sub-c.txt', 'test-sub-1/test-sub-sub-1/', 'test-sub-1/test-sub-sub-1/sub-sub-b.txt', 'test-sub-1/test-sub-sub-1/sub-sub-c.txt', 'test-sub-2/' ,'x.txt'];
fsEntries.forEach(entry => {
fileList.push(entry.relativePath);
});
expect(fileList).to.be.deep.equal(walkList);
});
expect(fileList).to.be.deep.equal(walkList);
it('takes no input', function() {
fsMerger = new FSMerge(['fixtures/test-1', 'fixtures/test-2', 'fixtures/test-3']).fs;
let fsEntries = fsMerger.entries();
let fileList = [];
let walkList = ['a.txt', 'b.txt', 'c.txt', 'd.txt', 'test-1/', 'test-1/b.txt', 'test-sub-1/', 'test-sub-1/sub-b.txt', 'test-sub-1/sub-c.txt', 'test-sub-1/test-sub-sub-1/', 'test-sub-1/test-sub-sub-1/sub-sub-b.txt', 'test-sub-1/test-sub-sub-1/sub-sub-c.txt', 'test-sub-2/' ,'x.txt'];
fsEntries.forEach(entry => {
fileList.push(entry.relativePath);
});
expect(fileList).to.be.deep.equal(walkList);
});
it('takes empty string as an input', function() {
fsMerger = new FSMerge(['fixtures/test-1', 'fixtures/test-2', 'fixtures/test-3']).fs;
let fsEntries = fsMerger.entries('');
let fileList = [];
let walkList = ['a.txt', 'b.txt', 'c.txt', 'd.txt', 'test-1/', 'test-1/b.txt', 'test-sub-1/', 'test-sub-1/sub-b.txt', 'test-sub-1/sub-c.txt', 'test-sub-1/test-sub-sub-1/', 'test-sub-1/test-sub-sub-1/sub-sub-b.txt', 'test-sub-1/test-sub-sub-1/sub-sub-c.txt', 'test-sub-2/' ,'x.txt'];
fsEntries.forEach(entry => {
fileList.push(entry.relativePath);
});
expect(fileList).to.be.deep.equal(walkList);
});
});

@@ -318,0 +340,0 @@ });

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc