From cda86833cdbe40e4521f7040304611b5564de07e Mon Sep 17 00:00:00 2001 From: Daniel Gudiel Date: Fri, 11 Nov 2022 09:39:31 -0600 Subject: [PATCH 1/3] adding function to return all files since rooot --- lib/object.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/object.js b/lib/object.js index 0e979778..a90c4c88 100644 --- a/lib/object.js +++ b/lib/object.js @@ -379,6 +379,24 @@ var out = { options.type = "nodebuffer"; } return this.generateInternalStream(options).toNodejsStream(onUpdate); - } + }, + + /** + * Return all files since root in the form {relativePath, file} + * @returns {Array} An array of items files + */ + getFilesSinceRoot: function(){ + var result = [] + // ignore warning about unwanted properties because this.files is a null prototype object + /* eslint-disable-next-line guard-for-in */ + for (filename in this.files) { + file = this.files[filename]; + relativePath = filename.slice(this.root.length, filename.length); + if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root + result.push(relativePath, file) + } + } + return result; + }, }; module.exports = out; From ad731d59772e245607cbb289ee0262a123df51da Mon Sep 17 00:00:00 2001 From: Daniel Gudiel Date: Fri, 11 Nov 2022 09:56:01 -0600 Subject: [PATCH 2/3] fixing vars declarations --- lib/object.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/object.js b/lib/object.js index a90c4c88..164278e7 100644 --- a/lib/object.js +++ b/lib/object.js @@ -386,7 +386,7 @@ var out = { * @returns {Array} An array of items files */ getFilesSinceRoot: function(){ - var result = [] + var result = [], filename, relativePath, file; // ignore warning about unwanted properties because this.files is a null prototype object /* eslint-disable-next-line guard-for-in */ for (filename in this.files) { From 346cf9145a1e9e75f9249726b4bdd2a6b91913a9 Mon Sep 17 00:00:00 2001 From: Daniel Gudiel Date: Fri, 11 Nov 2022 10:02:55 -0600 Subject: [PATCH 3/3] fixing object push in array --- lib/object.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/object.js b/lib/object.js index 164278e7..e9977124 100644 --- a/lib/object.js +++ b/lib/object.js @@ -393,7 +393,7 @@ var out = { file = this.files[filename]; relativePath = filename.slice(this.root.length, filename.length); if (relativePath && filename.slice(0, this.root.length) === this.root) { // the file is in the current root - result.push(relativePath, file) + result.push({relativePath:relativePath, file:file}) } } return result;