javascript - Check if file exists in sails.js -


I created a pal service to load javascript files, depending on its controller name (or page and / Or if there is a session).

I changed it (array) JS files into a res.local.js and in my layout. Loose it to include JS files in EJS, My HTML.

 For  (i = 0; i   

Question, how can I check that JS file exists before my inclusion in HTML?

In PHP, we have functioned in the name of the function, there is the same function with Sails.js?

Yes since you can create seals with Node.js.

This will remove the file from the array if it can not be found. You can load it in your view how you were before.

  fs = require ('fs'); (I = 0; i & lt; loadJS.length; i ++) {fs.exists (loadJS [i], function (present) {if (! Exists) {// array loadJS.splice (i, 1 ) remove from; }}); }    

Comments

Popular posts from this blog

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -