Making folders in glitch

javascript

#1

I was working on a bot for a while in visual studio and I wanted to transfer it to glitch because my app wasn’t online when my PC was off.
My whole code is built of folders and there no folders in glitch.
Is there a way to create a folder?


#2

Folders do exist in Glitch we just don’t have a nested filetree in the editor UI. So you can create or use a folder by including the path in your file name e.g. ‘public/index.html’ would be a file called ‘index.html’ in a folder called ‘public’.


#3

So can I do like:?
fs.readdir("./public/", (err, files) => {

if (err) console.error(err);

var jsfiles = files.filter(f => f.split(".").pop() === “js”);

if(jsfiles.length <= 0){ return console.log(“Couldn’t find commands.”)}

else {console.log(loading ${jsfiles.length} commands!);}


#4

That’s right - it’s a persistent file system, so you can run code against it.