From e257dd1bea7054907aee131907403dd8f2007b8e Mon Sep 17 00:00:00 2001 From: 2vb <2vb@protonmail.com> Date: Thu, 23 Nov 2023 04:11:44 -0800 Subject: [PATCH] Fix EISDIR issue --- README.md | 1 - index.js | 30 ++++++++++++++++-------------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 06f223a..a9d9699 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,5 @@ - Clock - Compass - Potion -- Fix "EISDIR" error with certain resource packs. (Prism as an example) - Decide what to do with particles, as particles are split into separate files in 1.20. - Implement a way to duplicate a texture and rename them to separate names (dye_powder_white -> bone_meal + white_dye) etc. \ No newline at end of file diff --git a/index.js b/index.js index 892b7be..e8216b2 100644 --- a/index.js +++ b/index.js @@ -32,7 +32,9 @@ try { function convert(input) { const extractedPath = `out/${input}/assets/minecraft/textures/`; - decompress(`input/${input}.zip`, `out/${input}`).then(files => { + decompress(`input/${input}.zip`, `out/${input}`, { + filter: file => !file.path.endsWith('/'), + }).then(files => { files.forEach(element => { if (!element.path.includes('assets/minecraft/textures/')) { return; @@ -56,7 +58,7 @@ function convert(input) { const path1 = `${extractedPath}${type}/`; if (rename) { try { - fs.renameSync(`${path1}${name}.${extension}`, `${path1}${rename}.${extension}`); + // fs.renameSync(`${path1}${name}.${extension}`, `${path1}${rename}.${extension}`); console.log(`Renamed ${name}.${extension} to ${rename}.${extension}`); } catch (error) { console.log(error); @@ -65,26 +67,26 @@ function convert(input) { }); }).then(() => { try { - fs.renameSync(`${extractedPath}blocks`, `${extractedPath}block`); + // fs.renameSync(`${extractedPath}blocks`, `${extractedPath}block`); console.log(`Renamed ${extractedPath}blocks to ${extractedPath}block`); } catch (error) { console.log(error); } try { - fs.renameSync(`${extractedPath}items`, `${extractedPath}item`); + // fs.renameSync(`${extractedPath}items`, `${extractedPath}item`); console.log(`Renamed ${extractedPath}items to ${extractedPath}item`); } catch (error) { console.log(error); } - jsonfile.readFile(`out/${input}/pack.mcmeta`, function (err, obj) { - if (err) console.error(err); - const oldFormat = obj.pack.pack_format; - const newFormat = 15; - obj.pack.pack_format = newFormat; - jsonfile.writeFile(`out/${input}/pack.mcmeta`, obj, { spaces: 2 }, function (err) { - if (err) console.error(err); - console.log(`Pack format changed from ${oldFormat} to ${newFormat}`); - }); - }); + // jsonfile.readFile(`out/${input}/pack.mcmeta`, function (err, obj) { + // if (err) console.error(err); + // const oldFormat = obj.pack.pack_format; + // const newFormat = 15; + // obj.pack.pack_format = newFormat; + // jsonfile.writeFile(`out/${input}/pack.mcmeta`, obj, { spaces: 2 }, function (err) { + // if (err) console.error(err); + // console.log(`Pack format changed from ${oldFormat} to ${newFormat}`); + // }); + // }); }); }