diff --git a/.gitignore b/.gitignore index bca833d82ca5713b93b6e4d3f4c25d13b1560bf0..187b924053ceb17e1d4bf8c138ea6acc67b39057 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 1f6880a7e35a8a9c5cc80c7b1771804435c60bc6..b7c1bffadf678d18b081b68e8ac42bfe6afb6d73 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 54c653e06a77a6c704349324680934f1af7c63f5..0000000000000000000000000000000000000000 --- 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 dbfef70c3bbf3c8d052202d02434d942fa4cfd21..ceb3951b14a82e025c2e4cecae06ef7c662c8427 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": {