Debian Codegraph @

lib/reporters/landing.js

raw symbols SCIP
1 "use strict";
2
3 /**
4 * @typedef {import('../runner.js')} Runner
5 */
6
7 /**
8 * @module Landing
9 */
10 /**
11 * Module dependencies.
12 */
13
14 var Basescip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Base. = require("./base"scip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/);
15 var inheritsscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/inherits. = require("../utils"scip-typescript npm mocha 11.7.7 lib/`utils.js`/).inherits;
16 var constantsscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/constants. = require("../runner"scip-typescript npm mocha 11.7.7 lib/`runner.js`/).constants;
17 var EVENT_RUN_BEGINscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/EVENT_RUN_BEGIN. = constants.EVENT_RUN_BEGIN;
18 var EVENT_RUN_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/EVENT_RUN_END. = constants.EVENT_RUN_END;
19 var EVENT_TEST_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/EVENT_TEST_END. = constants.EVENT_TEST_END;
20 var STATE_FAILEDscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/STATE_FAILED. = require("../runnable"scip-typescript npm mocha 11.7.7 lib/`runnable.js`/).constants.STATE_FAILED;
21
22 var cursorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/cursor. = Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..cursor;
23 var colorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/color. = Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..color;
24
25 /**
26 * Expose `Landing`.
27 */
28
29 exportsscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/ = module.exports = Landingscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().;
30
31 /**
32 * Airplane color.
33 */
34
35 Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..colors.plane = 0;
36
37 /**
38 * Airplane crash color.
39 */
40
41 Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..colors["plane crash"] = 31;
42
43 /**
44 * Runway color.
45 */
46
47 Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..colors.runway = 90;
48
49 /**
50 * Constructs a new `Landing` reporter instance.
51 *
52 * @public
53 * @class
54 * @memberof Mocha.reporters
55 * @extends Mocha.reporters.Base
56 * @param {Runner} runner - Instance triggers reporter actions.
57 * @param {Object} [options] - runner options
58 */
59 function Landingscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(runnerscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(runner), optionsscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(options)) {
60 Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..callscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Function#call().(this, runnerscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(runner), optionsscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(options));
61
62 var self = this;
63 var width = (Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base()..window.widthscip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/width0: * 0.75) | 0;
64 var stream = process.stdout;
65
66 var plane = colorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/color.("plane", "✈");
67 var crashed = -1;
68 var n = 0;
69 var total = 0;
70
71 function runway() {
72 var buf = Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#(width).joinscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#join().("-");
73 return " " + colorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/color.("runway", buf);
74 }
75
76 runnerscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(runner).on(EVENT_RUN_BEGINscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/EVENT_RUN_BEGIN., function () {
77 stream.write("\n\n\n ");
78 cursorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/cursor..hidescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/hide0:();
79 });
80
81 runnerscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(runner).on(EVENT_TEST_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/EVENT_TEST_END., function (test) {
82 // check if the plane crashed
83 var col = crashed === -1 ? ((width * ++n) / ++total) | 0 : crashed;
84 // show the crash
85 if (test.state === STATE_FAILEDscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/STATE_FAILED.) {
86 plane = colorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/color.("plane crash", "✈");
87 crashed = col;
88 }
89
90 // render landing strip
91 stream.write("\u001b[" + (width + 1) + "D\u001b[2A");
92 stream.write(runway());
93 stream.write("\n ");
94 stream.write(colorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/color.("runway", Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#(col).joinscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#join().("⋅")));
95 stream.write(plane);
96 stream.write(colorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/color.("runway", Arrayscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#(width - col).joinscip-typescript npm typescript 5.9.3 lib/`lib.es5.d.ts`/Array#join().("⋅") + "\n"));
97 stream.write(runway());
98 stream.write("\u001b[0m");
99 });
100
101 runnerscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing().(runner).once(EVENT_RUN_ENDscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/EVENT_RUN_END., function () {
102 cursorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/cursor..showscip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/show0:();
103 process.stdout.write("\n");
104 self.epilogue();
105 });
106
107 // if cursor is hidden when we ctrl-C, then it will remain hidden unless...
108 process.once("SIGINT", function () {
109 cursorscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/cursor..showscip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/show0:();
110 process.nextTick(function () {
111 process.kill(process.pid, "SIGINT");
112 });
113 });
114 }
115
116 /**
117 * Inherit from `Base.prototype`.
118 */
119 inheritsscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/inherits.(Landingscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing()., Basescip-typescript npm mocha 11.7.7 lib/reporters/`base.js`/Base().);
120
121 Landingscip-typescript npm mocha 11.7.7 lib/reporters/`landing.js`/Landing()..description = "Unicode landing strip";