Skip to content

Commit

Permalink
Merge pull request #30 from alessioalex/master
Browse files Browse the repository at this point in the history
CommonJS && AMD support
  • Loading branch information
adamschwartz committed May 10, 2014
2 parents d92da8a + 5706188 commit 4ffcd21
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
13 changes: 10 additions & 3 deletions log.coffee
Expand Up @@ -100,8 +100,15 @@ ffSupport = ->
# Export

if isIE() or (isFF() and not ffSupport()) or (isOpera() and not operaSupport()) or (isSafari() and not safariSupport())
window.log = _log
exportedLog = _log
else
window.log = log
exportedLog = log

window.log.l = _log
exportedLog.l = _log

if typeof define is 'function' and define.amd
define exportedLog
else if typeof exports isnt 'undefined'
module.exports = exportedLog
else
window.log = exportedLog
16 changes: 12 additions & 4 deletions log.js
@@ -1,5 +1,5 @@
(function() {
var ffSupport, formats, getOrderedMatches, hasMatches, isFF, isIE, isOpera, isSafari, log, makeArray, operaSupport, safariSupport, stringToArgs, _log;
var exportedLog, ffSupport, formats, getOrderedMatches, hasMatches, isFF, isIE, isOpera, isSafari, log, makeArray, operaSupport, safariSupport, stringToArgs, _log;

if (!(window.console && window.console.log)) {
return;
Expand Down Expand Up @@ -142,11 +142,19 @@
};

if (isIE() || (isFF() && !ffSupport()) || (isOpera() && !operaSupport()) || (isSafari() && !safariSupport())) {
window.log = _log;
exportedLog = _log;
} else {
window.log = log;
exportedLog = log;
}

window.log.l = _log;
exportedLog.l = _log;

if (typeof define === 'function' && define.amd) {
define(exportedLog);
} else if (typeof exports !== 'undefined') {
module.exports = exportedLog;
} else {
window.log = exportedLog;
}

}).call(this);
2 changes: 1 addition & 1 deletion log.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
@@ -1,9 +1,10 @@
{
"name": "log-with-style",
"version": "0.1.2",
"version": "0.1.3",
"description": "Console.log with style",
"author": "Adam Schwartz <adam.flynn.schwartz@gmail.com>",
"license": "MIT",
"main": "log.js",
"devDependencies": {
"grunt-contrib-coffee": "~0.7.0",
"coffee-script": "~1.6.3",
Expand All @@ -12,4 +13,4 @@
"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.5.3"
}
}
}

0 comments on commit 4ffcd21

Please sign in to comment.