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

CLI: coffee --watch fails on file that does not exist #985

Closed
ianb opened this issue Dec 27, 2010 · 8 comments
Closed

CLI: coffee --watch fails on file that does not exist #985

ianb opened this issue Dec 27, 2010 · 8 comments
Labels

Comments

@ianb
Copy link

ianb commented Dec 27, 2010

When using coffee --watch I have non-existent files in the directory (Emacs creates files like .#filename.coffee). It would be better to simply ignore these. Sample traceback:

/home/ianb/.node_libraries/.npm/coffee-script/1.0.0/package/lib/command.js:62
        throw new Error("File not found: " + source);
              ^
Error: File not found: static/.#site.coffee
  at /home/ianb/.node_libraries/.npm/coffee-script/1.0.0/package/lib/command.js:62:19
  at path.js:151:19
@TrevorBurnham
Copy link
Collaborator

So, what would the best precise solution be? Ignore files whose names start with ., or .#? There must be some precedence for this.

@TrevorBurnham
Copy link
Collaborator

Looking more closely, I see that command.coffee throws an error whenever a nonexistent file is encountered; I believe this line is left over from way back before support for directories was added. The behavior should be to throw an error only if the nonexistent file was given directly as an argument to coffee (in which case topLevel is true). So I believe the line should be changed from

throw new Error "File not found: #{source}" unless exists

to

throw new Error "File not found: #{source}" if topLevel and not exists

That way, you'd still get an error if you ran coffee -c .#filename.coffee, but you wouldn't get an error if such a file were momentarily in the directory you provided to coffee.

@ianb
Copy link
Author

ianb commented Dec 28, 2010

That sounds perfect to me.

@jashkenas
Copy link
Owner

Thanks for figuring this one out, Trevor. I've made the requested change at SHA: 83d424f.

stephank pushed a commit to stephank/coffee-script that referenced this issue May 14, 2011
@pmapcat
Copy link

pmapcat commented Jan 17, 2015

This issue appears in coffeescript 1.8.0 too.
File not found: .#screenshot.coffee
And watch then stops.
I am using command :

coffee --watch -o output -c ./ 

Strange thing, that this is also takes into account non coffee files. like

File not found: .#postinstall.sh

Thanks

@philc
Copy link

philc commented Sep 24, 2015

Can we reopen this bug? It has been regressed recently. I've reproduced this in coffeescript 1.9.3 and 1.10.0, and @Michaelleachim saw it in 1.8.0.

It's a very annoying bug for emacs developers, because operations within emacs which create temporary files and then delete them (like using magit to write a git commit message) crashes the coffeescript process.

@jashkenas jashkenas reopened this Sep 25, 2015
@jashkenas jashkenas removed the fixed label Sep 25, 2015
@celwell
Copy link
Contributor

celwell commented Oct 8, 2015

This has been annoying me as well. Is there a filter I can add to my watch dir command?

coffee -o . -cwb src

@GeoffreyBooth GeoffreyBooth changed the title coffee --watch fails on file that does not exist CLI: coffee --watch fails on file that does not exist May 5, 2017
@GeoffreyBooth
Copy link
Collaborator

I can’t seem to reproduce this. I tried running emacs and creating and saving, and opening and saving files. I also ran coffee -cwo ./dist/ ./src in one tab and touch .foo.coffee in another tab, and then rm .foo.coffee in that tab, and the watch task handled the events just fine:

19:33:50 - compiled ~/src/.foo.coffee
19:34:01 - removed ~/src/.foo.coffee

If someone can post steps to reproduce in current CoffeeScript, I’ll reopen.

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

No branches or pull requests

7 participants