From bd2158613ddfe2da930f691f04d5aea674c78e5f Mon Sep 17 00:00:00 2001 From: Paris Date: Tue, 3 May 2016 12:05:13 +0300 Subject: [PATCH] Make all add-ons CommonJS importable - Fix #52 - Rename `npm/nodejs project` documentation to `CommonJS environment` --- addons/attach/attach.js | 7 ++++++- addons/fit/fit.js | 7 ++++++- addons/fullscreen/fullscreen.js | 11 ++++++++--- addons/linkify/linkify.js | 7 ++++++- src/xterm.js | 2 +- 5 files changed, 27 insertions(+), 7 deletions(-) diff --git a/addons/attach/attach.js b/addons/attach/attach.js index e2ce145f..2788f8e7 100644 --- a/addons/attach/attach.js +++ b/addons/attach/attach.js @@ -7,7 +7,12 @@ */ (function (attach) { - if (typeof define == 'function') { + if (typeof exports === 'object' && typeof module === 'object') { + /* + * CommonJS environment + */ + module.exports = attach.call(this); + } else if (typeof define == 'function') { /* * Require.js is available */ diff --git a/addons/fit/fit.js b/addons/fit/fit.js index f913d4ea..c39b9cf1 100644 --- a/addons/fit/fit.js +++ b/addons/fit/fit.js @@ -12,7 +12,12 @@ * of columns) */ (function (fit) { - if (typeof define == 'function') { + if (typeof exports === 'object' && typeof module === 'object') { + /* + * CommonJS environment + */ + module.exports = fit.call(this); + } else if (typeof define == 'function') { /* * Require.js is available */ diff --git a/addons/fullscreen/fullscreen.js b/addons/fullscreen/fullscreen.js index 4816e951..4e3d0028 100644 --- a/addons/fullscreen/fullscreen.js +++ b/addons/fullscreen/fullscreen.js @@ -11,7 +11,12 @@ * fullscreen mode is being toggled. */ (function (fullscreen) { - if (typeof define == 'function') { + if (typeof exports === 'object' && typeof module === 'object') { + /* + * CommonJS environment + */ + module.exports = fullscreen.call(this); + } else if (typeof define == 'function') { /* * Require.js is available */ @@ -19,7 +24,7 @@ } else { /* * Plain browser environment - */ + */ fullscreen(this.Xterm); } })(function (Xterm) { @@ -36,4 +41,4 @@ this.element.classList[fn]('fullscreen'); }; -}); \ No newline at end of file +}); diff --git a/addons/linkify/linkify.js b/addons/linkify/linkify.js index 9834183b..ab3c041a 100644 --- a/addons/linkify/linkify.js +++ b/addons/linkify/linkify.js @@ -1,5 +1,10 @@ (function (linkify) { - if (typeof define == 'function') { + if (typeof exports === 'object' && typeof module === 'object') { + /* + * CommonJS environment + */ + module.exports = linkify.call(this); + } else if (typeof define == 'function') { /* * Require.js is available */ diff --git a/src/xterm.js b/src/xterm.js index 69b64511..6bec2030 100644 --- a/src/xterm.js +++ b/src/xterm.js @@ -34,7 +34,7 @@ (function (xterm) { if (typeof exports === 'object' && typeof module === 'object') { /* - * npm/nodejs project + * CommonJS environment */ module.exports = xterm.call(this); } else if (typeof define == 'function') {