Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/aiveraiva/cdn

File tree system made big brainly 🤯. Using Github Actions for updating.
https://github.com/aiveraiva/cdn

actions file-tree filesystem github

Last synced: about 2 months ago
JSON representation

File tree system made big brainly 🤯. Using Github Actions for updating.

Awesome Lists containing this project

README

        

# cdn

A file tree system made with very easy mechanic. Using Github Actions for updating.
I made this due to the scarcity of these kind of resources we are able to find on the internet, there are prob some exist libraries that I didnt found.
But anyways it took me a few minutes to make this simple script, which fits all my requirements I need and it is pretty need

# Explaination

This function basically creates the required html code for the website to work
It recursively searchs files in `src/`
and making its path for the later using of turning the paths into code
Thats what this function does.

```js
function generateFileTree(dir) {
const files = fs.readdirSync(dir);

let fileTree = '

    ';
    files.forEach((file) => {
    const fullPath = path.join(dir, file);
    const relativePath = path.relative(rootDir, fullPath);
    const isDirectory = fs.statSync(fullPath).isDirectory();

    if (isDirectory) {
    fileTree += `


  • ${file}`;
    fileTree += generateFileTree(fullPath);
    fileTree += '
  • ';
    } else {
    fileTree += `
  • ${file}
  • `;
    }
    });
    fileTree += '
';
return fileTree;
}
```