elm-lang / elm-package

Command line tool to share Elm libraries
BSD 3-Clause "New" or "Revised" License
214 stars 66 forks source link

Locate for nearest elm-package.json instead of assuming cwd #196

Closed dynajoe closed 7 years ago

dynajoe commented 8 years ago

elm-make uses this library to determine where elm-stuff and elm-package.json directories are.

Should this library provide absolute paths relative to the nearest elm-package.json.

This would greatly help knowing the root directory for a project when using elm-make and possibly reduce the times this issue occurs unintentionally:

https://github.com/elm-lang/elm-make/issues/2

dynajoe commented 8 years ago

It's worth noting that this behavior has precedent:

https://docs.npmjs.com/cli/prefix https://docs.npmjs.com/cli/bin

stkb commented 8 years ago

I agree. I actually came across this issue using elm-repl, but it affects all the cli tools. I was surprised that running the command in a sub-folder of a project tries to create a new project, rather than looking for a project in a parent folder first. As @joeandaverde says, this is how npm works.

Maybe there are cases where this is the desirable behaviour but I can't think of them. Most likely it would be done by accident.

wgottschalk-RMS commented 7 years ago

It's annoying when using Elm in a Phoenix application. Maybe there's a way to just specify the path to the elmpackage.json in either package.json file or as a command line argument?

evancz commented 7 years ago

This is how things will work with any elm command in the upcoming release. I will likely add a little note if you are not in the root though so there are no surprises.