Skip to content

Commit

Permalink
UMD for unix_formatting #418
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Aug 16, 2018
1 parent 9955b57 commit 84b6081
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -4,6 +4,7 @@

### Features
* linksNoFollow option (default false)
* add UMD for utility files [#418](https://github.com/jcubic/jquery.terminal/issues/418)

### Bug Fixes
* handling backspaces in unix formatting [#409](https://github.com/jcubic/jquery.terminal/issues/409)
Expand Down
1 change: 1 addition & 0 deletions js/jquery.terminal.d.ts
Expand Up @@ -392,6 +392,7 @@ type TerminalOptions = {
processRPCResponse?: null | JQueryTerminal.processRPCResponseFunction;
completionEscape?: boolean;
convertLinks?: boolean;
unixFormattingEscapeBrackets?: boolean; // provided by unix_formatting
extra?: any;
tabs?: number;
historySize?: number;
Expand Down
43 changes: 37 additions & 6 deletions js/unix_formatting.js
Expand Up @@ -13,12 +13,43 @@
* Released under the MIT license
*
*/
/* global jQuery */
(function($) {
if (!$.terminal) {
throw new Error('$.terminal is not defined');
/* global jQuery, define, global, require, module */
(function(factory) {
var root = typeof window !== 'undefined' ? window : global;
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
// istanbul ignore next
define(['jquery', 'jquery.terminal'], factory);
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function(root, jQuery) {
if (jQuery === undefined) {
// require('jQuery') returns a factory that requires window to
// build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop
// if it's defined (how jquery works)
if (typeof window !== 'undefined') {
jQuery = require('jquery');
} else {
jQuery = require('jquery')(root);
}
}
if (!jQuery.fn.terminal) {
if (typeof window !== 'undefined') {
require('jquery.terminal');
} else {
require('jquery.terminal')(jQuery);
}
}
factory(jQuery);
return jQuery;
};
} else {
// Browser
// istanbul ignore next
factory(root.jQuery);
}

})(function($) {
$.terminal.defaults.unixFormattingEscapeBrackets = false;
// we match characters and html entities because command line escape brackets
// echo don't, when writing formatter always process html entitites so it work
Expand Down Expand Up @@ -515,4 +546,4 @@

$.terminal.defaults.formatters.unshift($.terminal.overtyping);
$.terminal.defaults.formatters.unshift($.terminal.from_ansi);
})(jQuery);
});

0 comments on commit 84b6081

Please sign in to comment.