mirror of
https://github.com/whyour/qinglong.git
synced 2025-07-07 11:56:08 +08:00
脚本管理忽略符号文件
This commit is contained in:
parent
62168979e3
commit
2713942a68
|
@ -34,7 +34,14 @@ export default (app: Router) => {
|
||||||
const logger: Logger = Container.get('logger');
|
const logger: Logger = Container.get('logger');
|
||||||
try {
|
try {
|
||||||
let result = [];
|
let result = [];
|
||||||
const blacklist = ['node_modules', '.git', '.pnpm'];
|
const blacklist = [
|
||||||
|
'node_modules',
|
||||||
|
'.git',
|
||||||
|
'.pnpm',
|
||||||
|
'pnpm-lock.yaml',
|
||||||
|
'yarn.lock',
|
||||||
|
'package-lock.json',
|
||||||
|
];
|
||||||
if (req.query.path) {
|
if (req.query.path) {
|
||||||
const targetPath = path.join(
|
const targetPath = path.join(
|
||||||
config.scriptPath,
|
config.scriptPath,
|
||||||
|
|
|
@ -251,34 +251,39 @@ export async function readDirs(
|
||||||
): Promise<IFile[]> {
|
): Promise<IFile[]> {
|
||||||
const relativePath = path.relative(baseDir, dir);
|
const relativePath = path.relative(baseDir, dir);
|
||||||
const files = await fs.readdir(dir);
|
const files = await fs.readdir(dir);
|
||||||
const result: IFile[] = await Promise.all(
|
const result: IFile[] = [];
|
||||||
files
|
|
||||||
.filter((x) => !blacklist.includes(x))
|
for (const file of files) {
|
||||||
.map(async (file: string) => {
|
const subPath = path.join(dir, file);
|
||||||
const subPath = path.join(dir, file);
|
const stats = await fs.stat(subPath);
|
||||||
const stats = await fs.stat(subPath);
|
const key = path.join(relativePath, file);
|
||||||
const key = path.join(relativePath, file);
|
|
||||||
if (stats.isDirectory()) {
|
if (blacklist.includes(file) || stats.isSymbolicLink()) {
|
||||||
return {
|
continue;
|
||||||
title: file,
|
}
|
||||||
key,
|
|
||||||
type: 'directory',
|
if (stats.isDirectory()) {
|
||||||
parent: relativePath,
|
const children = await readDirs(subPath, baseDir, blacklist, sort);
|
||||||
mtime: stats.mtime.getTime(),
|
result.push({
|
||||||
children: (await readDirs(subPath, baseDir)).sort(sort),
|
title: file,
|
||||||
};
|
key,
|
||||||
}
|
type: 'directory',
|
||||||
return {
|
parent: relativePath,
|
||||||
title: file,
|
mtime: stats.mtime.getTime(),
|
||||||
type: 'file',
|
children: children.sort(sort),
|
||||||
isLeaf: true,
|
});
|
||||||
key,
|
} else {
|
||||||
parent: relativePath,
|
result.push({
|
||||||
size: stats.size,
|
title: file,
|
||||||
mtime: stats.mtime.getTime(),
|
type: 'file',
|
||||||
};
|
key,
|
||||||
}),
|
parent: relativePath,
|
||||||
);
|
size: stats.size,
|
||||||
|
mtime: stats.mtime.getTime(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result.sort(sort);
|
return result.sort(sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user