bin/fileTree.js
function buildTree(directory, barrelName, logger) {
    logger(`Building directory tree for ${utilities_1.convertPathSeparator(directory)}`);
    const names = fs_1.default.readdirSync(directory);
    const result = {
        directories: [],
        files: [],
        name: path_1.default.basename(directory),
        path: utilities_1.convertPathSeparator(directory)
    };
    names.forEach((name) => {
        const fullPath = path_1.default.join(directory, name);
        if (fs_1.default.statSync(fullPath).isDirectory()) {
            result.directories.push(buildTree(fullPath, barrelName, logger));
        }
        else {
            const convertedPath = utilities_1.convertPathSeparator(fullPath);
            const file = {
                name,
                path: convertedPath
            };
            result.files.push(file);
            if (file.name === barrelName) {
                logger(`Found existing barrel @ ${convertedPath}`);
                result.barrel = file;
            }
        }
    });
    return result;
}
function buildTree(directory, barrelName, logger) {
    logger(`Building directory tree for ${utilities_1.convertPathSeparator(directory)}`);
    const names = fs_1.default.readdirSync(directory);
    const result = {
        directories: [],
        files: [],
        name: path_1.default.basename(directory),
        path: utilities_1.convertPathSeparator(directory)
    };
    names.forEach((name) => {
        const fullPath = path_1.default.join(directory, name);
        if (fs_1.default.statSync(fullPath).isDirectory()) {
            result.directories.push(buildTree(fullPath, barrelName, logger));
        }
        else {
            const convertedPath = utilities_1.convertPathSeparator(fullPath);
            const file = {
                name,
                path: convertedPath
            };
            result.files.push(file);
            if (file.name === barrelName) {
                logger(`Found existing barrel @ ${convertedPath}`);
                result.barrel = file;
            }
        }
    });
    return result;
}
function buildTree ( directory , barrelName , logger ) { logger ( ` ${ utilities_1 . convertPathSeparator ( directory ) } ` ) ; const names = fs_1 . default . readdirSync ( directory ) ; const result = { directories : [ ] , files : [ ] , name : path_1 . default . basename ( directory ) , path : utilities_1 . convertPathSeparator ( directory ) } ; names . forEach ( ( name ) => { const fullPath = path_1 . default . join ( directory , name ) ; if ( fs_1 . default . statSync ( fullPath ) . isDirectory ( ) ) { result . directories . push ( buildTree ( fullPath , barrelName , logger ) ) ; } else { const convertedPath = utilities_1 . convertPathSeparator ( fullPath ) ; const file = { name , path : convertedPath } ; result . files . push ( file ) ; if ( file . name === barrelName ) { logger ( ` ${ convertedPath } ` ) ; result . barrel = file ; } } } ) ; return result ; }
Build directory information recursively.
Build directory information recursively .