Merge VS Code 1.30.1 (#4092)

This commit is contained in:
Matt Irvine
2019-02-21 17:17:23 -08:00
committed by GitHub
parent a764a481f3
commit 826856c390
11465 changed files with 119542 additions and 255338 deletions

View File

@@ -17,7 +17,7 @@ async function getTree(fsPath, level) {
const element = path.basename(fsPath);
const stat = await fs.stat(fsPath);
if (!stat.isDirectory() || element === '.git' || element === '.build' || level >= 3) {
if (!stat.isDirectory() || element === '.git' || element === '.build' || level >= 2) {
return { element };
}
@@ -26,6 +26,37 @@ async function getTree(fsPath, level) {
return { element, collapsible: true, collapsed: false, children };
}
async function readdir(relativePath) {
const absolutePath = relativePath ? path.join(root, relativePath) : root;
const childNames = await fs.readdir(absolutePath);
const childStats = await Promise.all(childNames.map(async name => await fs.stat(path.join(absolutePath, name))));
const result = [];
for (let i = 0; i < childNames.length; i++) {
const name = childNames[i];
const path = relativePath ? `${relativePath}/${name}` : name;
const stat = childStats[i];
if (stat.isFile()) {
result.push({ type: 'file', name, path });
} else if (!stat.isDirectory() || name === '.git' || name === '.build') {
continue;
} else {
result.push({ type: 'dir', name, path });
}
}
result.sort((a, b) => {
if (a.type === b.type) {
return a.name < b.name ? -1 : 1;
}
return a.type === 'dir' ? -1 : 1;
});
return result;
}
app.use(serve('public'));
app.use(mount('/static', serve('../../out')));
app.use(_.get('/api/ls', async ctx => {
@@ -33,7 +64,13 @@ app.use(_.get('/api/ls', async ctx => {
const absolutePath = path.join(root, relativePath);
ctx.body = await getTree(absolutePath, 0);
}))
}));
app.use(_.get('/api/readdir', async ctx => {
const relativePath = ctx.query.path;
ctx.body = await readdir(relativePath);
}));
app.listen(3000);
console.log('http://localhost:3000');