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

Possible feature to prevent overwriting source files #1171

Open
flip111 opened this issue Jan 18, 2024 · 5 comments
Open

Possible feature to prevent overwriting source files #1171

flip111 opened this issue Jan 18, 2024 · 5 comments

Comments

@flip111
Copy link
Contributor

flip111 commented Jan 18, 2024

When i tried bundle it overwrite an existing index.js, luckily i had that checked into version control. However spago could put a // generated by spago at the top of the generated file. Then when bundling it could check if that files exist, and if it does check whether it can find // generated by spago then overwrite without asking.

@JordanMartinez
Copy link
Collaborator

It's not clear to me why this is a problem. What was your workflow that caused this to happen?
Bundling code produces an artifact from source code that can be recreated by bundling again. IMO, overwriting the same file with a new bundle from slightly changed source code is normal. If one wrote some index.js file not based on source code and then overwrite the file with the output of a bundle call, that sounds more like user error to me.

@flip111
Copy link
Contributor Author

flip111 commented Jan 18, 2024

There are plenty of tools that either ask if you want to overwrite and/or have special flags to force overwrite. They ask to prevent user error.

@JordanMartinez
Copy link
Collaborator

To me, this creates more of a problem than a solution. If this was supported and I want to run spago bundle -p some-app, I now always need to pass --force to it to get the workflow I explain above. So, such a feature would impede my workflow.

@flip111
Copy link
Contributor Author

flip111 commented Jan 18, 2024

That's not what i am suggesting. It would overwrite automatically without flag when it detects // generated by spago

@f-f
Copy link
Member

f-f commented Mar 1, 2024

Before using spago bundle it's a good idea to ask oneself where this bundle will be put. The help text has a flag to override this location.

We should note in the help text for the flag what the default for outfile is, and yeah checking if the file was generated by spago is a good idea so we don't accidentally overwrite things.

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

No branches or pull requests

3 participants