Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/aiveraiva/cdn
- Owner: AiverAiva
- License: mit
- Created: 2023-07-29T13:07:58.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-10-17T03:28:05.000Z (2 months ago)
- Last Synced: 2024-10-19T05:53:25.858Z (2 months ago)
- Topics: actions, file-tree, filesystem, github
- Language: JavaScript
- Homepage: https://cdn.weikuwu.me/
- Size: 25.9 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 = '
- ';
-
${file}`;
fileTree += generateFileTree(fullPath);
fileTree += ' ';
- ${file} `;
files.forEach((file) => {
const fullPath = path.join(dir, file);
const relativePath = path.relative(rootDir, fullPath);
const isDirectory = fs.statSync(fullPath).isDirectory();
if (isDirectory) {
fileTree += `
} else {
fileTree += `
}
});
fileTree += '
return fileTree;
}
```