• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

glorious-codes / glorious-demo / 971b12eb-089e-42e4-89d6-04e2d7329d1c

pending completion
971b12eb-089e-42e4-89d6-04e2d7329d1c

Pull #107

circleci

GitHub
build(deps): bump minimist from 1.2.5 to 1.2.6
Pull Request #107: build(deps): bump minimist from 1.2.5 to 1.2.6

62 of 62 branches covered (100.0%)

Branch coverage included in aggregate %.

273 of 273 relevant lines covered (100.0%)

10.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/scripts/components/terminal-application/terminal-application.js
1
import textService from '../../services/text/text';
2
import { Application } from '../application/application';
3
import { TerminalCommandLine } from '../terminal-command-line/terminal-command-line';
4
import { TerminalResponseLine } from '../terminal-response-line/terminal-response-line';
5

6
export class TerminalApplication extends Application {
7
  constructor(container, options = {}){
12✔
8
    super('terminal', options);
15✔
9
    this.container = container;
15✔
10
    this.container.appendChild(this.element);
15✔
11
    this.setCommandLines([]);
15✔
12
    this.configOptions(options);
15✔
13
  }
14
  configOptions(options){
15
    this.setWindowTitle(buildWindowTitle(options));
15✔
16
    this.setPromptString(buildPromptString(options));
15✔
17
  }
18
  setCommandLines(lines){
19
    this.commandLines = lines;
15✔
20
  }
21
  setPromptString(string){
22
    this.promptString = string;
16✔
23
  }
24
  command({ command, promptString }, onComplete){
25
    if(promptString)
7✔
26
      this.setPromptString(promptString);
1✔
27
    setLastCommandLineWrittenAsInactive(this.commandLines);
7✔
28
    writeCommandLine(this, command, onComplete);
7✔
29
  }
30
  respond({ response }, onComplete){
31
    const responseLines = textService.removeBlankFirstLine(response);
3✔
32
    for(let i = 0; i < responseLines.length; i++)
3✔
33
      this.addContent(buildResponseLineElement(responseLines[i]));
3✔
34
    onComplete();
3✔
35
  }
36
}
37

38
function buildWindowTitle(options){
39
  return options.windowTitle || 'bash';
15✔
40
}
41

42
function buildPromptString(options){
43
  return options.promptString || '~/demo $';
15✔
44
}
45

46
function setLastCommandLineWrittenAsInactive(commandLines){
47
  if(commandLines.length)
7✔
48
    commandLines[commandLines.length - 1].setInactive();
1✔
49
}
50

51
function writeCommandLine(terminalApplication, command, onComplete){
52
  const line = new TerminalCommandLine(terminalApplication.promptString);
7✔
53
  terminalApplication.commandLines.push(line);
7✔
54
  terminalApplication.addContent(line.element);
7✔
55
  line.setActive();
7✔
56
  line.command(command, onComplete);
7✔
57
}
58

59
function buildResponseLineElement(lineText){
60
  const line = new TerminalResponseLine();
3✔
61
  line.setText(lineText);
3✔
62
  return line.element;
3✔
63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc