Skip to content
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

Recursive folder deletion #13

Closed
stephan281094 opened this issue Sep 1, 2015 · 6 comments
Closed

Recursive folder deletion #13

stephan281094 opened this issue Sep 1, 2015 · 6 comments

Comments

@stephan281094
Copy link

The problem

When executing meteor-build-client ../ in de Meteor application folder. It deletes everything. Looking at the code, this makes sense. But when you want to export the static files one folder higher, it's unexpected behavior and can even cause users to lose all their work.

Steps to reproduce

  • Create a folder called foo/ and cd into it.

  • meteor create app

  • cd app

  • meteor-build-client ../

  • You get the following error:

    Bundling Meteor app...
    
    fs.js:612
      return binding.rmdir(pathModule._makeLong(path));
                     ^
    Error: ENOENT, no such file or directory './../'
        at Object.fs.rmdirSync (fs.js:612:18)
        at deleteFolderRecursive (/usr/local/lib/node_modules/meteor-build-client/meteor.js:48:12)
        at Object.module.exports.build (/usr/local/lib/node_modules/meteor-build-client/meteor.js:56:9)
        at /usr/local/lib/node_modules/meteor-build-client/main.js:68:20
        at null._onTimeout (/usr/local/lib/node_modules/meteor-build-client/queue.js:41:11)
        at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)

    And the foo/ folder is completely empty.

In this scenario the user would lose all files inside foo/, including the folder where the Meteor application is located. This should be fixed.

@lukeadams
Copy link
Contributor

Two things I think would fix it:

  • We should warn when deleting if the directory already exists and isn't empty (whoops, deleted ~/). Can override with --force/-f for build systems or scripts
  • Check if buildDir is part of the folder tree for the current meteor app (path.resolve('./'))

@frozeman
Copy link
Owner

frozeman commented Oct 7, 2015

I think we should prevent using the parent folder all together, as its quite weird to put you build files in the parent folder, where it also contains the source folder then.

@stephan281094
Copy link
Author

I'm closing this due to inactivity.

@matikucharski
Copy link

I think this should be reopened and it should be added warning that not empty dir is going ot be deleted. We can add flag to skip the warning but I think this could save some ppls from accidentally running the script in /home folder ;)

@dr-dimitru
Copy link
Collaborator

Reopen, thanks to @matikucharski

@dr-dimitru dr-dimitru reopened this Jun 29, 2022
dr-dimitru added a commit that referenced this issue Oct 22, 2022
__Changes:__

- 🔧 Fix for #13 — Ask user to prompt overwriting output directory, thanks to @matikucharski
- ✨ Added `-y` `--yci`  — Flags to skip prompt and warnings
- 🤝 Compatibility with `[email protected]`
@dr-dimitru
Copy link
Collaborator

@matikucharski @stephan281094 solved in v1.3.0

Feel free to reopen it in case if the issue is still persists on your end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants