I have created a sails service to load the javascript files depends on its controller name (or page and/or if there's a session).
I passed this (array of) JS files into an res.local.js and in my layout.ejs, loop it to include the js file into my html.
for (i = 0; i < loadJS.length; i++) {
<script src="<%- loadJS[i] %>.js"></script>
}
Question, how can I check if the JS file exists before including it in my html?
In PHP, we have function called file_exists, is there a similar function with sails.js?