Skip to content

Commit

Permalink
1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
acegoal07 committed Oct 3, 2022
1 parent 774b74a commit 0a8d642
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class JsonEditor {
* Copy's the data from a file into the file your editing
*
* @param {String} path The path to the JSON file
* @param {Boolean} layout The is used to add a layout out to the data being writen to the file
* @param {Boolean} layout The is used to add a layout out to the data being written to the file
* @returns {JsonEditor} The `JsonEditor` instance
*/
writeCopy(path, layout = false) {
Expand Down Expand Up @@ -197,7 +197,7 @@ class JsonEditor {
if (!joiner) {
throw new Error("arrayToString ERROR: joiner is null");
}
if (data.length = 1) return data;
if (data.length === 1) return data;
return data.join(joiner);
}

Expand Down Expand Up @@ -376,7 +376,7 @@ class JsonEditor {
*/
getKeys(path = null) {
if (!path) {
const data = this.get(path);
const data = this.data;
if (typeof data != "object") {
throw new Error("getKeys ERROR: The data is not an object");
}
Expand Down Expand Up @@ -477,7 +477,6 @@ exports.createFile = async(path, data = `{}`) => {
}
fs.writeFile(path, data, function (error) {
if (error) throw error;
return;
});
}

Expand All @@ -495,7 +494,6 @@ exports.deleteFile = async(path) => {
}
fs.unlink(path, function (error) {
if (error) throw error;
return;
});
}

Expand All @@ -519,7 +517,6 @@ exports.copyFile = async(path, copyPath = null) => {
} else {
fs.copyFile(path, copyPath, function (error) {
if (error) throw error;
return
});
}
}
Expand All @@ -544,7 +541,6 @@ exports.moveFile = async(oldPath, newPath) => {
if (error) throw error;
});
exports.deleteFile(oldPath);
return;
}

/**
Expand All @@ -565,7 +561,6 @@ exports.renameFile = async(path, newName) => {
}
fs.rename(path, path.replace(path.split(/[\\/]/).pop(), newName), function (error) {
if (error) throw error;
return;
});
}

Expand Down Expand Up @@ -603,6 +598,7 @@ exports.readAllFiles = async(path, format = "Map") => {
let array = new Array();
for (const file of fs.readdirSync(path)) {
if (!file.toLowerCase().endsWith(".json")) {
void(0);
} else {
array.push(
{
Expand All @@ -617,6 +613,7 @@ exports.readAllFiles = async(path, format = "Map") => {
const map = new Map();
for (const file of fs.readdirSync(path)) {
if (!file.toLowerCase().endsWith(".json")) {
void(0);
} else {
map.set(file.toLowerCase().replace(".json", ""), rJson(`${path}/${file}`));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@acegoal07/json-editor",
"version": "1.1.0",
"version": "1.1.1",
"description": "A simple json file editor",
"main": "index.js",
"types": "types",
Expand Down

0 comments on commit 0a8d642

Please sign in to comment.