I know it is possible to just read the program.json file, which lists all assets: https://github.com/meteor/meteor/issues/1328#issuecomment-22913769
But this sort of feels wrong, and I couldn't find out whether this will be supported going forward. The documentation on assets itself is still a little sparse in this regard (http://docs.meteor.com/#assets).
Is there a best practice on how to list all assets?
I don't know if this is a best practice, but I got most of the way there by using meteor package https://github.com/peerlibrary/meteor-fs (which is a thin wrapper around https://nodejs.org/api/fs.html) and doing some poking around. Turns out the assets are put into a folder called app/
.
Here's what my code looked like:
if (Meteor.isServer) {
Meteor.startup(function() {
// clear database and load everything in the articles folder
fs.readdir("assets/app/", function(err, files) {
if (err) throw err;
files.forEach(function (val, ind, arr) {
console.log(val);
});
});
});
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With