Assume I've created an Harmonic site at /site/.
After fiddling a bit in the terminal, my CWD is /site/posts/en/.
If I try to run any Harmonic command (e.g. harmonic run) it will throw the "this is not an Harmonic project yet" error.
I believe we can walk up the directory hierarchy to find the closest harmonic.json file and assume it is the root of the Harmonic site. This approach is used by jshint, jscs, npm, git, etc.
IIRC there is an npm package that implements this functionality, but anyway we would only need a couple lines of code to cover our use cases I believe.
Use case
Assume I've created an Harmonic site at
/site/
. After fiddling a bit in the terminal, my CWD is/site/posts/en/
. If I try to run any Harmonic command (e.g.harmonic run
) it will throw the "this is not an Harmonic project yet" error.I believe we can walk up the directory hierarchy to find the closest
harmonic.json
file and assume it is the root of the Harmonic site. This approach is used by jshint, jscs, npm, git, etc.IIRC there is an npm package that implements this functionality, but anyway we would only need a couple lines of code to cover our use cases I believe.