urish / angular-moment

Moment.JS directives for Angular.JS (timeago and more)
MIT License
2.6k stars 397 forks source link

Fix for "Electron" #265

Closed gantrior closed 7 years ago

gantrior commented 7 years ago

Hi, angular-moment does not load in Electron "renderer" environment. It is because module and module.exports exists in Electron environment, but the followed code does not

angularMoment(require('angular'), require('moment'));
module.exports = 'angularMoment';

code bellow works for me

urish commented 7 years ago

Thanks for the PR!

I believe that commit 517f42f should solve this. Can you please check and confirm?

gantrior commented 7 years ago

Nope, does not work on Electron. (typeof require === 'function') is evaluated as True in Electron renderer environment, so the call falls into module.exports = angularMoment(require('angular'), require('moment')) which does not

My PR is based on the issue where is solved how to detect Electron environment, and it works quite well

urish commented 7 years ago

Got it! Can you please update the PR for the latest code version?

gantrior commented 7 years ago

rebased on the latest changes (release 1.0.0)

coveralls commented 7 years ago

Coverage Status

Coverage increased (+0.03%) to 93.243% when pulling dccdbbcea6421def5c000c6c88f53affc103d5ad on gantrior:master into 448e472efb22bd51bdc210cf80c7d296b63e0aaa on urish:master.

urish commented 7 years ago

Thanks!