加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
creatFileList.js 1.42 KB
一键复制 编辑 原始数据 按行查看 历史
nullice 提交于 2017-04-28 20:01 . 1
const path = require("path")
const fs = require("fs")
var SCAN_PATH = path.join(__dirname)
// var GIT_URL = "http://ui-dna.doc.design-enzyme.com"
var GIT_URL = "http://doc.design-enzyme.com"
var NOTSCAN = /^.git/
fileList = []
console.info("\x1b[94m", "扫描目录----------------------------", SCAN_PATH)
scanDir(SCAN_PATH)
function scanDir(inPath) {
var dir = fs.readdirSync(inPath)
for (x in dir) {
if (NOTSCAN.test(dir[x])) {
console.log("skip ", dir[x])
continue;
}
var _thisPath = path.join(inPath, dir[x])
var isDirectory = false
try {
var stat = fs.statSync(_thisPath)
isDirectory = stat.isDirectory()
} catch (e) {
console.error(e)
}
if (isDirectory) {
scanDir(_thisPath)
} else {
console.log("+", _thisPath)
var filename = path.relative(SCAN_PATH, _thisPath)
var filename = filename.replace(/\@/g, "%40").replace(/\\/g, "/")
fileList.push({url:"http://nullice.oschina.io/ui-dna-cn/"+filename, name:path.relative(SCAN_PATH, _thisPath)})
}
}
}
console.log(fileList)
var html ="<html>"
for(var x in fileList)
{
html+= `<br><a href="${fileList[x].url}" traget="_blank"> ${fileList[x].url}</a>\n`
}
console.log(html)
fs.writeFileSync(path.join(__dirname,"index.html"), html)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化