Then I load these files in both webpack from the root of the project, and running unit tests from the tests directory (ie. cd tests && mocha **/*.test.js).
Expected
It would find the files located in its own directory and parse them.
Actual
Webpack reports a file not found error trying to load databases.yml. So I change the directory to be relative to where I'm running webpack from (ie. inc/file config/databases.yml). This works for webpack, but then mocha reports an error when running tests because it can't find config/databases.yml.
Explanation
Since lib/file.js uses process.cwd() as its base, the actual path to the file is dependent on how I run js-yaml. This results in the path behavior being very unpredictable.
Thanks for making this an issue, Joe. I felt kinda creepy-crawly about doing it the way I originally did it, and it is now fixed. Please give version 1.2.0 a spin.
I have a directory structure like the following (example demonstrating my actual setup):
and I want to assign the objects loaded from
databases.yml
andassetHosts.yml
to top-level keys in each ofdevelopment.yml
andproduction.yml
like so:Then I load these files in both webpack from the root of the project, and running unit tests from the
tests
directory (ie.cd tests && mocha **/*.test.js
).Expected
It would find the files located in its own directory and parse them.
Actual
Webpack reports a file not found error trying to load
databases.yml
. So I change the directory to be relative to where I'm running webpack from (ie.inc/file config/databases.yml
). This works for webpack, but then mocha reports an error when running tests because it can't findconfig/databases.yml
.Explanation
Since
lib/file.js
usesprocess.cwd()
as its base, the actual path to the file is dependent on how I runjs-yaml
. This results in the path behavior being very unpredictable.