mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 12:19:20 +00:00
sample compressed tree
This commit is contained in:
24
test/tree/tree.js
Normal file
24
test/tree/tree.js
Normal file
@@ -0,0 +1,24 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
function collect(location) {
|
||||
const element = path.basename(location);
|
||||
const stat = fs.statSync(location);
|
||||
|
||||
if (!stat.isDirectory()) {
|
||||
return { element };
|
||||
}
|
||||
|
||||
const children = fs.readdirSync(location)
|
||||
.map(child => path.join(location, child))
|
||||
.map(collect);
|
||||
|
||||
return { element, children };
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(collect(process.cwd())));
|
||||
Reference in New Issue
Block a user