Skip to content

Commit

Permalink
(breaking) fix echo before login #912
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Dec 30, 2023
1 parent 49b9407 commit 1ec9bfc
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 27 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
@@ -1,4 +1,6 @@
## 2.38.0
### Breaking
* `onInit` runs before login
### Features
* add support for BigInt numbers when parsing commands
* add `--line-thickness` CSS variable to cursor animation
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -8,7 +8,7 @@
[![npm](https://img.shields.io/badge/npm-DEV-blue.svg)](https://www.npmjs.com/package/jquery.terminal)
![bower](https://img.shields.io/badge/bower-DEV-yellow.svg)
[![Build and test](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml/badge.svg?branch=devel&event=push)](https://github.com/jcubic/jquery.terminal/actions/workflows/build.yaml)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&e7c0298275d2f8608b0d02bda85fe16d)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
[![Coverage Status](https://coveralls.io/repos/github/jcubic/jquery.terminal/badge.svg?branch=devel&1e503cbcdc04527035c1339cc8696c05)](https://coveralls.io/github/jcubic/jquery.terminal?branch=devel)
![NPM Downloads](https://img.shields.io/npm/dm/jquery.terminal.svg?style=flat)
[![jsDelivr Downloads](https://data.jsdelivr.com/v1/package/npm/jquery.terminal/badge?style=rounded&n=1)](https://www.jsdelivr.com/package/npm/jquery.terminal)
[![Paid Support](https://img.shields.io/badge/paid-support-354465.svg)](https://support.jcubic.pl/)
Expand Down
14 changes: 14 additions & 0 deletions __tests__/terminal.spec.js
Expand Up @@ -5529,6 +5529,20 @@ describe('Terminal plugin', function() {
expect(term.token(true)).toEqual(token);
expect(term.get_prompt()).toEqual('$$$ ');
});
it('should echo during login #912', async () => {
var term = $('<div/>').terminal({}, {
login: function(user, password) {
return 'TOKEN';
},
greetings: false
});
term.echo('HELLO');
expect(term.get_output()).toEqual('HELLO');
await term.exec(['foo', 'bar']);
term.echo('WORLD');
const output = 'HELLO\nlogin: foo\npassword: ***\nWORLD';
expect(term.get_output()).toEqual(output);
});
});
describe('settings', function() {
var term = $('<div/>').appendTo('body').terminal();
Expand Down
25 changes: 17 additions & 8 deletions js/jquery.terminal-2.37.2.js
Expand Up @@ -41,9 +41,9 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sat, 25 Nov 2023 14:19:12 +0000
* Date: Sat, 30 Dec 2023 14:11:18 +0000
*/
/* global define, Map */
/* global define, Map, BigInt */
/* eslint-disable */
/* istanbul ignore next */
(function(ctx) {
Expand Down Expand Up @@ -5278,7 +5278,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 25 Nov 2023 14:19:12 +0000',
date: 'Sat, 30 Dec 2023 14:11:18 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -8726,7 +8726,7 @@
}
clear_loging_storage();
fire_event('onAfterlogout', [], true);
self.login(global_login_fn, true, initialize);
self.login(global_login_fn, true, start);
}
// ---------------------------------------------------------------------
function clear_loging_storage() {
Expand Down Expand Up @@ -8794,7 +8794,6 @@
));
}
command_line.set('');
init_queue.resolve();
if (!silent && is_function(interpreter.onStart)) {
interpreter.onStart.call(self, self);
}
Expand Down Expand Up @@ -8875,9 +8874,13 @@
}
}
// ---------------------------------------------------------------------
function initialize() {
function start() {
prepare_top_interpreter();
init_queue.resolve();
show_greetings();
}
// ---------------------------------------------------------------------
function initialize() {
if (lines.length) {
// for case when showing long error before init
if (echo_delay.length) {
Expand Down Expand Up @@ -11342,6 +11345,8 @@
while (interpreters.size() > 1) {
interpreters.pop();
}
prepare_top_interpreter();
show_greetings();
initialize();
});
return self;
Expand Down Expand Up @@ -12315,10 +12320,14 @@
self.disable();
}
// -------------------------------------------------------------
// Run Login
// initialization
// -------------------------------------------------------------
if (is_function(global_login_fn)) {
self.login(global_login_fn, true, initialize);
self.login(global_login_fn, true, start);
init_queue.resolve();
initialize();
} else {
start();
initialize();
}
// -------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal-2.37.2.min.js

Large diffs are not rendered by default.

19 changes: 14 additions & 5 deletions js/jquery.terminal-src.js
Expand Up @@ -8726,7 +8726,7 @@
}
clear_loging_storage();
fire_event('onAfterlogout', [], true);
self.login(global_login_fn, true, initialize);
self.login(global_login_fn, true, start);
}
// ---------------------------------------------------------------------
function clear_loging_storage() {
Expand Down Expand Up @@ -8794,7 +8794,6 @@
));
}
command_line.set('');
init_queue.resolve();
if (!silent && is_function(interpreter.onStart)) {
interpreter.onStart.call(self, self);
}
Expand Down Expand Up @@ -8875,9 +8874,13 @@
}
}
// ---------------------------------------------------------------------
function initialize() {
function start() {
prepare_top_interpreter();
init_queue.resolve();
show_greetings();
}
// ---------------------------------------------------------------------
function initialize() {
if (lines.length) {
// for case when showing long error before init
if (echo_delay.length) {
Expand Down Expand Up @@ -11342,6 +11345,8 @@
while (interpreters.size() > 1) {
interpreters.pop();
}
prepare_top_interpreter();
show_greetings();
initialize();
});
return self;
Expand Down Expand Up @@ -12315,10 +12320,14 @@
self.disable();
}
// -------------------------------------------------------------
// Run Login
// initialization
// -------------------------------------------------------------
if (is_function(global_login_fn)) {
self.login(global_login_fn, true, initialize);
self.login(global_login_fn, true, start);
init_queue.resolve();
initialize();
} else {
start();
initialize();
}
// -------------------------------------------------------------
Expand Down
25 changes: 17 additions & 8 deletions js/jquery.terminal.js
Expand Up @@ -41,9 +41,9 @@
*
* broken image by Sophia Bai from the Noun Project (CC-BY)
*
* Date: Sat, 25 Nov 2023 14:19:12 +0000
* Date: Sat, 30 Dec 2023 14:11:18 +0000
*/
/* global define, Map */
/* global define, Map, BigInt */
/* eslint-disable */
/* istanbul ignore next */
(function(ctx) {
Expand Down Expand Up @@ -5278,7 +5278,7 @@
// -------------------------------------------------------------------------
$.terminal = {
version: 'DEV',
date: 'Sat, 25 Nov 2023 14:19:12 +0000',
date: 'Sat, 30 Dec 2023 14:11:18 +0000',
// colors from https://www.w3.org/wiki/CSS/Properties/color/keywords
color_names: [
'transparent', 'currentcolor', 'black', 'silver', 'gray', 'white',
Expand Down Expand Up @@ -8726,7 +8726,7 @@
}
clear_loging_storage();
fire_event('onAfterlogout', [], true);
self.login(global_login_fn, true, initialize);
self.login(global_login_fn, true, start);
}
// ---------------------------------------------------------------------
function clear_loging_storage() {
Expand Down Expand Up @@ -8794,7 +8794,6 @@
));
}
command_line.set('');
init_queue.resolve();
if (!silent && is_function(interpreter.onStart)) {
interpreter.onStart.call(self, self);
}
Expand Down Expand Up @@ -8875,9 +8874,13 @@
}
}
// ---------------------------------------------------------------------
function initialize() {
function start() {
prepare_top_interpreter();
init_queue.resolve();
show_greetings();
}
// ---------------------------------------------------------------------
function initialize() {
if (lines.length) {
// for case when showing long error before init
if (echo_delay.length) {
Expand Down Expand Up @@ -11342,6 +11345,8 @@
while (interpreters.size() > 1) {
interpreters.pop();
}
prepare_top_interpreter();
show_greetings();
initialize();
});
return self;
Expand Down Expand Up @@ -12315,10 +12320,14 @@
self.disable();
}
// -------------------------------------------------------------
// Run Login
// initialization
// -------------------------------------------------------------
if (is_function(global_login_fn)) {
self.login(global_login_fn, true, initialize);
self.login(global_login_fn, true, start);
init_queue.resolve();
initialize();
} else {
start();
initialize();
}
// -------------------------------------------------------------
Expand Down
4 changes: 2 additions & 2 deletions js/jquery.terminal.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/jquery.terminal.min.js.map

Large diffs are not rendered by default.

0 comments on commit 1ec9bfc

Please sign in to comment.