-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deletion of pre-existing route folders in urara.clean()
#4
Comments
🤔 hmm... my suggestion is to put all the folders in the /urara/ directory, but this really needs improvement. I may update in the next few days, or welcome PR 👌 |
I'll try to put something together this weekend 😅 |
progress: It is currently possible to delete all files copied from /urara/, but it is difficult to delete all empty directories. const cleanFile = src =>
fs.readdir(src, { withFileTypes: true }).then(files => {
files.forEach(file => {
const dest = path.join(src, file.name)
file.isDirectory()
? cleanFile(dest)
: file.name.startsWith('.')
? log('cyan', 'ignore file', dest)
: rmFile(dest)
})
})
cleanFile('urara') |
What if it kept track of all the files/dirs copied in the build step? Maybe in some sort of context or an array that can keep state? That would remove all the guesswork and be quite precise, all it would need to do is iterate through the array and delete items that match. |
💀 It would be too complicated in this case. const cleanDir = src =>
fs.readdir(src, { withFileTypes: true }).then(files => {
files.forEach(file => {
const dest = path.join(src, file.name)
file.isDirectory()
? rmDir(dest)
: file.name.startsWith('.')
? log('cyan', 'ignore file', dest)
: rmFile(dest)
})
}) |
Update: |
What's the problem that you're running into with file removal? I might have a chance to look at it this week. Just after looking briefly at the code I had a few ideas jump out:
edited: after re-reading, the first and second options I originally suggested were basically the same thing, just the first was more complicated. |
Hello, my idea is to keep it simple while solving the problem, so the newest solution is to scan the files under the Copying goes well, the problem is with cleanup - when it starts to determine if the folder is empty, the files that need to be removed have not yet been removed. |
Ah, interesting. Things have been crazy with work, but I think I'll have some time Thursday to look at it. My thought was to see if it'd be viable to create two arrays (one for |
So, I was playing around with the javascript file a bit, but decided to just start over from scratch using typescript, at least for the file management part just because it's a bit more familiar. It's not the prettiest solution but it works and I generally just prefer the clarity of functions over assigning lambdas. I wrote the method from scratch, then I found Anyways, here's a gist with the output (it's similar for both). There's some logging to clean up or move over to The output of either method is similar, except that the Filling out the rest of the copy and removal should be pretty easy, I just wanted to make sure you'd be comfortable with the solution before I finish implementing it. |
Great work! |
Yeah, I figured I’d leave both options there. One thing I thought of is adding a |
It works fine, I will try to combine it with the existing remove function tomorrow.
Considering that urara.js will only handle files copied from the |
😥 Ok, now the problem comes back to removing dirs... |
Sorry for the delayed response. I missed the message about removal. I have a few questions:
|
Ah, no problem.
|
urara/urara.js
Lines 86 to 96 in b5520f9
I noticed that pre-existing folders in the routes directory are blown away by the
urara.clean
function, as you can see in the section of code highlighted above. Urara apparently just deletes all routes folders arbitrarily, without checking if it was a route that it created or not.This means if I had a subfolder for photos, for example, after running the dev server urara would destroy them and not even realize it made a mistake. This has huge implications down the line. Unfortunately I don't have the bandwidth to draft a PR right now, but I'll still try to squeeze it in.
That being said: wonderful project you have here so far, I'm quite eager to try it in production as soon as possible 😉
The text was updated successfully, but these errors were encountered: