Files
azuredatastudio/test/tree/tree.js
Anthony Dresser 1d56a17f32 Merge from vscode 2cfc8172e533e50c90e6a3152f6bfb1f82f963f3 (#6516)
* Merge from vscode 2cfc8172e533e50c90e6a3152f6bfb1f82f963f3

* fix tests
2019-07-28 15:15:24 -07:00

25 lines
797 B
JavaScript

/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const path = require('path');
const fs = require('fs');
function collect(location) {
const element = { name: path.basename(location) };
const stat = fs.statSync(location);
if (!stat.isDirectory()) {
return { element, incompressible: true };
}
const children = fs.readdirSync(location)
.map(child => path.join(location, child))
.map(collect);
return { element, children };
}
console.log(JSON.stringify(collect(process.cwd())));