Reputation: 125
I have an ember project. The root folder has a file called version which just says 1.1.0
In the root folder I also have my client folder (ember project) with a config folder and then environment.js for my app variables.
Im trying to read from the version file and add its contents in the environment.js file as a varaible.
Im currently trying like this: version: $.getJSON("../../VERSION")
but im getting the unexpected identifier error. With Node I would use: version: fs.readFileSync(__dirname + '/../VERSION').toString().trim(),
How would I do this with ember? thanks
Upvotes: 0
Views: 26
Reputation: 65113
You'll need to get the version in environment.js and expose it as an ENV key-value pair in the ENV hash/object.
environment.js is the only[1] file with access to things outside of the frontend / browser environment.
Once you have your ENV saying what version you have (maybe via fs
), you can then import the enviroment via import ENV from 'app-name/config/environment'
, and access your version via ENV.versionPropertyThingThatYouMade
hope this helps!
[1] there are others, but that's not important right now
Upvotes: 1