From bd08f523a6fdc688b8b0fc61f5cd88e8a0cabd70 Mon Sep 17 00:00:00 2001 From: Wuruipeng Date: Wed, 3 Apr 2024 10:30:55 +0800 Subject: [PATCH] =?UTF-8?q?init=EF=BC=9A=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=9F=BA=E7=A1=80=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - README.md | 1 - node-folder.js | 68 -------------------------------------------------- package.json | 1 - 4 files changed, 71 deletions(-) delete mode 100644 node-folder.js diff --git a/.gitignore b/.gitignore index bca833d..187b924 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,3 @@ yarn-error.log* node_modules .eslintcache package-lock.json -folder.txt diff --git a/README.md b/README.md index 1f6880a..b7c1bff 100644 --- a/README.md +++ b/README.md @@ -143,7 +143,6 @@ [File] .gitignore // git 排除项配置 [File] index.html // 项目根文件 [File] main.js // 项目入口文件 -[File] node-folder.js // 目录结构生成配置 [File] package-lock.json // 依赖版本信息 [File] package.json // 依赖项指令配置 [File] README.md // 项目文档 diff --git a/node-folder.js b/node-folder.js deleted file mode 100644 index 54c653e..0000000 --- a/node-folder.js +++ /dev/null @@ -1,68 +0,0 @@ -const fs = require('fs') -const path = require('path') - -function generateDirectoryText( - dirPath, - indentation = '', - excludedFolders = [] -) { - const files = fs.readdirSync(dirPath).sort((a, b) => { - // 获取文件路径 - const filePathA = path.join(dirPath, a) - const filePathB = path.join(dirPath, b) - - // 获取文件的stats信息 - const statsA = fs.statSync(filePathA) - const statsB = fs.statSync(filePathB) - - // 若其中一个为文件夹,则优先显示文件夹 - if (statsA.isDirectory() && !statsB.isDirectory()) { - return -1 - } - if (!statsA.isDirectory() && statsB.isDirectory()) { - return 1 - } - - // 若两者都为文件夹或都为文件,则按照默认排序 - return a.localeCompare(b) - }) - - let directoryText = '' - for (const file of files) { - const filePath = path.join(dirPath, file) - const stats = fs.statSync(filePath) - - // 检查当前文件或文件夹是否在排除列表中 - if (excludedFolders.includes(file)) { - continue // 若在排除列表中,则跳过当前文件或文件夹 - } - - if (stats.isDirectory()) { - directoryText += `${indentation}[Dir] ${file}\n` - directoryText += generateDirectoryText( - filePath, - `${indentation} `, - excludedFolders - ) - } else { - directoryText += `${indentation}[File] ${file}\n` - } - } - - return directoryText -} - -// 指定要生成目录文本的文件夹路径 -const folderPath = './' - -// 指定要排除的文件夹列表 -const excludedFolders = ['.git', 'node_modules', '.eslintcache', 'folder.txt'] - -const directoryText = generateDirectoryText(folderPath, '', excludedFolders) - -// 指定要保存目录文本的文件路径 -const outputPath = 'folder.txt' - -fs.writeFileSync(outputPath, directoryText) - -console.log(`目录信息已保存到 ${outputPath} 文件中。`) diff --git a/package.json b/package.json index dbfef70..ceb3951 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,6 @@ "scripts": { "start": "electron .", "pack": "electron-builder", - "structure": "node node-folder.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { -- Gitee