mocha 5.1.1 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/CHANGELOG.md +686 -984
  2. package/README.md +2 -1
  3. package/{images → assets/growl}/error.png +0 -0
  4. package/{images → assets/growl}/ok.png +0 -0
  5. package/bin/_mocha +4 -595
  6. package/bin/mocha +121 -61
  7. package/bin/options.js +6 -39
  8. package/browser-entry.js +21 -17
  9. package/lib/browser/growl.js +165 -2
  10. package/lib/browser/progress.js +11 -11
  11. package/lib/{template.html → browser/template.html} +0 -0
  12. package/lib/browser/tty.js +2 -2
  13. package/lib/cli/cli.js +68 -0
  14. package/lib/cli/commands.js +13 -0
  15. package/lib/cli/config.js +79 -0
  16. package/lib/cli/index.js +9 -0
  17. package/lib/cli/init.js +37 -0
  18. package/lib/cli/node-flags.js +69 -0
  19. package/lib/cli/one-and-dones.js +70 -0
  20. package/lib/cli/options.js +330 -0
  21. package/lib/cli/run-helpers.js +337 -0
  22. package/lib/cli/run-option-metadata.js +76 -0
  23. package/lib/cli/run.js +297 -0
  24. package/lib/context.js +14 -14
  25. package/lib/errors.js +141 -0
  26. package/lib/growl.js +136 -0
  27. package/lib/hook.js +5 -16
  28. package/lib/interfaces/bdd.js +16 -13
  29. package/lib/interfaces/common.js +62 -18
  30. package/lib/interfaces/exports.js +5 -8
  31. package/lib/interfaces/qunit.js +10 -10
  32. package/lib/interfaces/tdd.js +12 -11
  33. package/lib/mocha.js +477 -256
  34. package/lib/mocharc.json +10 -0
  35. package/lib/pending.js +1 -5
  36. package/lib/reporters/base.js +95 -117
  37. package/lib/reporters/doc.js +23 -9
  38. package/lib/reporters/dot.js +19 -13
  39. package/lib/reporters/html.js +82 -47
  40. package/lib/reporters/json-stream.js +43 -23
  41. package/lib/reporters/json.js +32 -23
  42. package/lib/reporters/landing.js +16 -9
  43. package/lib/reporters/list.js +19 -11
  44. package/lib/reporters/markdown.js +18 -12
  45. package/lib/reporters/min.js +8 -4
  46. package/lib/reporters/nyan.js +42 -35
  47. package/lib/reporters/progress.js +12 -7
  48. package/lib/reporters/spec.js +23 -12
  49. package/lib/reporters/tap.js +250 -32
  50. package/lib/reporters/xunit.js +61 -35
  51. package/lib/runnable.js +152 -95
  52. package/lib/runner.js +296 -248
  53. package/lib/stats-collector.js +83 -0
  54. package/lib/suite.js +294 -75
  55. package/lib/test.js +16 -15
  56. package/lib/utils.js +419 -146
  57. package/mocha.js +4589 -2228
  58. package/package.json +137 -38
  59. package/lib/ms.js +0 -94
  60. package/lib/reporters/base.js.orig +0 -498
  61. package/lib/reporters/json.js.orig +0 -128
package/bin/mocha CHANGED
@@ -3,75 +3,135 @@
3
3
  'use strict';
4
4
 
5
5
  /**
6
- * This tiny wrapper file checks for known node flags and appends them
7
- * when found, before invoking the "real" _mocha(1) executable.
6
+ * This wrapper executable checks for known node flags and appends them when found, before invoking the "real" _mocha(1) executable.
7
+ *
8
+ * @module bin/mocha
9
+ * @private
8
10
  */
9
11
 
10
- const spawn = require('child_process').spawn;
11
- const path = require('path');
12
- const getOptions = require('./options');
13
- const args = [path.join(__dirname, '_mocha')];
14
-
15
- // Load mocha.opts into process.argv
16
- // Must be loaded here to handle node-specific options
17
- getOptions();
18
-
19
- process.argv.slice(2).forEach(arg => {
20
- const flag = arg.split('=')[0];
21
-
22
- switch (flag) {
23
- case '-d':
24
- args.unshift('--debug');
25
- args.push('--no-timeouts');
26
- break;
27
- case 'debug':
28
- case '--debug':
29
- case '--debug-brk':
30
- case '--inspect':
31
- case '--inspect-brk':
32
- args.unshift(arg);
33
- args.push('--no-timeouts');
34
- break;
35
- case '-gc':
36
- case '--expose-gc':
37
- args.unshift('--expose-gc');
38
- break;
39
- case '--gc-global':
40
- case '--es_staging':
41
- case '--no-deprecation':
42
- case '--no-warnings':
43
- case '--prof':
44
- case '--log-timer-events':
45
- case '--throw-deprecation':
46
- case '--trace-deprecation':
47
- case '--trace-warnings':
48
- case '--use_strict':
49
- case '--allow-natives-syntax':
50
- case '--perf-basic-prof':
51
- case '--napi-modules':
52
- args.unshift(arg);
53
- break;
54
- default:
55
- if (arg.indexOf('--harmony') === 0) {
56
- args.unshift(arg);
57
- } else if (arg.indexOf('--trace') === 0) {
58
- args.unshift(arg);
59
- } else if (arg.indexOf('--icu-data-dir') === 0) {
60
- args.unshift(arg);
61
- } else if (arg.indexOf('--max-old-space-size') === 0) {
62
- args.unshift(arg);
63
- } else if (arg.indexOf('--preserve-symlinks') === 0) {
64
- args.unshift(arg);
65
- } else {
66
- args.push(arg);
67
- }
68
- break;
12
+ const {deprecate, warn} = require('../lib/utils');
13
+ const {spawn} = require('child_process');
14
+ const {loadOptions} = require('../lib/cli/options');
15
+ const {
16
+ unparseNodeFlags,
17
+ isNodeFlag,
18
+ impliesNoTimeouts
19
+ } = require('../lib/cli/node-flags');
20
+ const unparse = require('yargs-unparser');
21
+ const debug = require('debug')('mocha:cli:mocha');
22
+ const {aliases} = require('../lib/cli/run-option-metadata');
23
+ const nodeEnv = require('node-environment-flags');
24
+
25
+ const mochaPath = require.resolve('./_mocha');
26
+ const mochaArgs = {};
27
+ const nodeArgs = {};
28
+
29
+ const opts = loadOptions(process.argv.slice(2));
30
+ debug('loaded opts', opts);
31
+
32
+ /**
33
+ * Given option/command `value`, disable timeouts if applicable
34
+ * @param {string} [value] - Value to check
35
+ * @ignore
36
+ */
37
+ const disableTimeouts = value => {
38
+ if (impliesNoTimeouts(value)) {
39
+ debug(`option "${value}" disabled timeouts`);
40
+ mochaArgs.timeout = 0;
41
+ delete mochaArgs.timeouts;
42
+ delete mochaArgs.t;
43
+ }
44
+ };
45
+
46
+ /**
47
+ * If `value` begins with `v8-` and is not explicitly `v8-options`, remove prefix
48
+ * @param {string} [value] - Value to check
49
+ * @returns {string} `value` with prefix (maybe) removed
50
+ * @ignore
51
+ */
52
+ const trimV8Option = value =>
53
+ value !== 'v8-options' && /^v8-/.test(value) ? value.slice(3) : value;
54
+
55
+ // sort options into "node" and "mocha" buckets
56
+ Object.keys(opts).forEach(opt => {
57
+ if (isNodeFlag(opt)) {
58
+ nodeArgs[trimV8Option(opt)] = opts[opt];
59
+ disableTimeouts(opt);
60
+ } else {
61
+ mochaArgs[opt] = opts[opt];
69
62
  }
70
63
  });
71
64
 
65
+ // Native debugger handling
66
+ // see https://nodejs.org/api/debugger.html#debugger_debugger
67
+ // look for 'debug' or 'inspect' that would launch this debugger,
68
+ // remove it from Mocha's opts and prepend it to Node's opts.
69
+ // also coerce depending on Node.js version.
70
+ // A deprecation warning will be printed by node, if applicable.
71
+ // (mochaArgs._ are "positional" arguments, not prefixed with - or --)
72
+ if (/^(debug|inspect)$/.test(mochaArgs._[0])) {
73
+ const command = mochaArgs._.shift();
74
+ disableTimeouts(command);
75
+ // don't conflict with inspector
76
+ ['debug', 'inspect', 'debug-brk', 'inspect-brk']
77
+ .filter(opt => opt in nodeArgs || opt in mochaArgs)
78
+ .forEach(opt => {
79
+ warn(`command "${command}" provided; --${opt} ignored`);
80
+ delete nodeArgs[opt];
81
+ delete mochaArgs[opt];
82
+ });
83
+ nodeArgs._ = [
84
+ parseInt(
85
+ process.version
86
+ .slice(1)
87
+ .split('.')
88
+ .shift(),
89
+ 10
90
+ ) >= 8
91
+ ? 'inspect'
92
+ : 'debug'
93
+ ];
94
+ }
95
+
96
+ // allow --debug to invoke --inspect on Node.js v8 or newer.
97
+ ['debug', 'debug-brk']
98
+ .filter(opt => opt in nodeArgs && !nodeEnv.has(opt))
99
+ .forEach(opt => {
100
+ const newOpt = opt === 'debug' ? 'inspect' : 'inspect-brk';
101
+ warn(
102
+ `"--${opt}" is not available in Node.js ${
103
+ process.version
104
+ }; use "--${newOpt}" instead.`
105
+ );
106
+ nodeArgs[newOpt] = nodeArgs[opt];
107
+ mochaArgs.timeout = false;
108
+ debug(`--${opt} -> ${newOpt}`);
109
+ delete nodeArgs[opt];
110
+ });
111
+
112
+ // historical
113
+ if (nodeArgs.gc) {
114
+ deprecate(
115
+ '"-gc" is deprecated and will be removed from a future version of Mocha. Use "--gc-global" instead.'
116
+ );
117
+ nodeArgs['gc-global'] = nodeArgs.gc;
118
+ delete nodeArgs.gc;
119
+ }
120
+
121
+ debug('final node args', nodeArgs);
122
+
123
+ const args = [].concat(
124
+ unparseNodeFlags(nodeArgs),
125
+ mochaPath,
126
+ unparse(mochaArgs, {alias: aliases})
127
+ );
128
+
129
+ debug(`exec ${process.execPath} w/ args:`, args);
130
+
72
131
  const proc = spawn(process.execPath, args, {
73
132
  stdio: 'inherit'
74
133
  });
134
+
75
135
  proc.on('exit', (code, signal) => {
76
136
  process.on('exit', () => {
77
137
  if (signal) {
package/bin/options.js CHANGED
@@ -1,43 +1,10 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * Dependencies.
3
+ /*
4
+ * This module is deprecated and will be removed in a future version of Mocha.
5
+ * @deprecated Deprecated in v6.0.0; source moved into {@link module:lib/cli/options lib/cli/options module}.
6
+ * @module
7
+ * @exports module:lib/cli/options
5
8
  */
6
9
 
7
- const fs = require('fs');
8
-
9
- /**
10
- * Export `getOptions`.
11
- */
12
-
13
- module.exports = getOptions;
14
-
15
- /**
16
- * Get options.
17
- */
18
-
19
- function getOptions () {
20
- if (process.argv.length === 3 && (process.argv[2] === '-h' || process.argv[2] === '--help')) {
21
- return;
22
- }
23
-
24
- const optsPath = process.argv.indexOf('--opts') === -1
25
- ? 'test/mocha.opts'
26
- : process.argv[process.argv.indexOf('--opts') + 1];
27
-
28
- try {
29
- const opts = fs.readFileSync(optsPath, 'utf8')
30
- .replace(/\\\s/g, '%20')
31
- .split(/\s/)
32
- .filter(Boolean)
33
- .map(value => value.replace(/%20/g, ' '));
34
-
35
- process.argv = process.argv
36
- .slice(0, 2)
37
- .concat(opts.concat(process.argv.slice(2)));
38
- } catch (err) {
39
- // ignore
40
- }
41
-
42
- process.env.LOADED_MOCHA_OPTS = true;
43
- }
10
+ module.exports = require('../lib/cli/options');
package/browser-entry.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * Shim process.stdout.
8
8
  */
9
9
 
10
- process.stdout = require('browser-stdout')({level: false});
10
+ process.stdout = require('browser-stdout')({label: false});
11
11
 
12
12
  var Mocha = require('./lib/mocha');
13
13
 
@@ -17,7 +17,7 @@ var Mocha = require('./lib/mocha');
17
17
  * @return {undefined}
18
18
  */
19
19
 
20
- var mocha = new Mocha({ reporter: 'html' });
20
+ var mocha = new Mocha({reporter: 'html'});
21
21
 
22
22
  /**
23
23
  * Save timer references to avoid Sinon interfering (see GH-237).
@@ -38,12 +38,12 @@ var originalOnerrorHandler = global.onerror;
38
38
  * Revert to original onerror handler if previously defined.
39
39
  */
40
40
 
41
- process.removeListener = function (e, fn) {
41
+ process.removeListener = function(e, fn) {
42
42
  if (e === 'uncaughtException') {
43
43
  if (originalOnerrorHandler) {
44
44
  global.onerror = originalOnerrorHandler;
45
45
  } else {
46
- global.onerror = function () {};
46
+ global.onerror = function() {};
47
47
  }
48
48
  var i = uncaughtExceptionHandlers.indexOf(fn);
49
49
  if (i !== -1) {
@@ -56,9 +56,9 @@ process.removeListener = function (e, fn) {
56
56
  * Implements uncaughtException listener.
57
57
  */
58
58
 
59
- process.on = function (e, fn) {
59
+ process.on = function(e, fn) {
60
60
  if (e === 'uncaughtException') {
61
- global.onerror = function (err, url, line) {
61
+ global.onerror = function(err, url, line) {
62
62
  fn(new Error(err + ' (' + url + ':' + line + ')'));
63
63
  return !mocha.allowUncaught;
64
64
  };
@@ -74,9 +74,9 @@ mocha.suite.removeAllListeners('pre-require');
74
74
  var immediateQueue = [];
75
75
  var immediateTimeout;
76
76
 
77
- function timeslice () {
77
+ function timeslice() {
78
78
  var immediateStart = new Date().getTime();
79
- while (immediateQueue.length && (new Date().getTime() - immediateStart) < 100) {
79
+ while (immediateQueue.length && new Date().getTime() - immediateStart < 100) {
80
80
  immediateQueue.shift()();
81
81
  }
82
82
  if (immediateQueue.length) {
@@ -90,7 +90,7 @@ function timeslice () {
90
90
  * High-performance override of Runner.immediately.
91
91
  */
92
92
 
93
- Mocha.Runner.immediately = function (callback) {
93
+ Mocha.Runner.immediately = function(callback) {
94
94
  immediateQueue.push(callback);
95
95
  if (!immediateTimeout) {
96
96
  immediateTimeout = setTimeout(timeslice, 0);
@@ -102,8 +102,8 @@ Mocha.Runner.immediately = function (callback) {
102
102
  * This is useful when running tests in a browser because window.onerror will
103
103
  * only receive the 'message' attribute of the Error.
104
104
  */
105
- mocha.throwError = function (err) {
106
- uncaughtExceptionHandlers.forEach(function (fn) {
105
+ mocha.throwError = function(err) {
106
+ uncaughtExceptionHandlers.forEach(function(fn) {
107
107
  fn(err);
108
108
  });
109
109
  throw err;
@@ -114,7 +114,7 @@ mocha.throwError = function (err) {
114
114
  * Normally this would happen in Mocha.prototype.loadFiles.
115
115
  */
116
116
 
117
- mocha.ui = function (ui) {
117
+ mocha.ui = function(ui) {
118
118
  Mocha.prototype.ui.call(this, ui);
119
119
  this.suite.emit('pre-require', global, null, this);
120
120
  return this;
@@ -124,9 +124,9 @@ mocha.ui = function (ui) {
124
124
  * Setup mocha with the given setting options.
125
125
  */
126
126
 
127
- mocha.setup = function (opts) {
127
+ mocha.setup = function(opts) {
128
128
  if (typeof opts === 'string') {
129
- opts = { ui: opts };
129
+ opts = {ui: opts};
130
130
  }
131
131
  for (var opt in opts) {
132
132
  if (opts.hasOwnProperty(opt)) {
@@ -140,7 +140,7 @@ mocha.setup = function (opts) {
140
140
  * Run mocha, returning the Runner.
141
141
  */
142
142
 
143
- mocha.run = function (fn) {
143
+ mocha.run = function(fn) {
144
144
  var options = mocha.options;
145
145
  mocha.globals('location');
146
146
 
@@ -155,10 +155,14 @@ mocha.run = function (fn) {
155
155
  mocha.invert();
156
156
  }
157
157
 
158
- return Mocha.prototype.run.call(mocha, function (err) {
158
+ return Mocha.prototype.run.call(mocha, function(err) {
159
159
  // The DOM Document is not available in Web Workers.
160
160
  var document = global.document;
161
- if (document && document.getElementById('mocha') && options.noHighlighting !== true) {
161
+ if (
162
+ document &&
163
+ document.getElementById('mocha') &&
164
+ options.noHighlighting !== true
165
+ ) {
162
166
  Mocha.utils.highlightTags('code');
163
167
  }
164
168
  if (fn) {
@@ -1,5 +1,168 @@
1
1
  'use strict';
2
2
 
3
- // just stub out growl
3
+ /**
4
+ * Web Notifications module.
5
+ * @module Growl
6
+ */
4
7
 
5
- module.exports = require('../utils').noop;
8
+ /**
9
+ * Save timer references to avoid Sinon interfering (see GH-237).
10
+ */
11
+ var Date = global.Date;
12
+ var setTimeout = global.setTimeout;
13
+ var EVENT_RUN_END = require('../runner').constants.EVENT_RUN_END;
14
+
15
+ /**
16
+ * Checks if browser notification support exists.
17
+ *
18
+ * @public
19
+ * @see {@link https://caniuse.com/#feat=notifications|Browser support (notifications)}
20
+ * @see {@link https://caniuse.com/#feat=promises|Browser support (promises)}
21
+ * @see {@link Mocha#growl}
22
+ * @see {@link Mocha#isGrowlCapable}
23
+ * @return {boolean} whether browser notification support exists
24
+ */
25
+ exports.isCapable = function() {
26
+ var hasNotificationSupport = 'Notification' in window;
27
+ var hasPromiseSupport = typeof Promise === 'function';
28
+ return process.browser && hasNotificationSupport && hasPromiseSupport;
29
+ };
30
+
31
+ /**
32
+ * Implements browser notifications as a pseudo-reporter.
33
+ *
34
+ * @public
35
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/notification|Notification API}
36
+ * @see {@link https://developers.google.com/web/fundamentals/push-notifications/display-a-notification|Displaying a Notification}
37
+ * @see {@link Growl#isPermitted}
38
+ * @see {@link Mocha#_growl}
39
+ * @param {Runner} runner - Runner instance.
40
+ */
41
+ exports.notify = function(runner) {
42
+ var promise = isPermitted();
43
+
44
+ /**
45
+ * Attempt notification.
46
+ */
47
+ var sendNotification = function() {
48
+ // If user hasn't responded yet... "No notification for you!" (Seinfeld)
49
+ Promise.race([promise, Promise.resolve(undefined)])
50
+ .then(canNotify)
51
+ .then(function() {
52
+ display(runner);
53
+ })
54
+ .catch(notPermitted);
55
+ };
56
+
57
+ runner.once(EVENT_RUN_END, sendNotification);
58
+ };
59
+
60
+ /**
61
+ * Checks if browser notification is permitted by user.
62
+ *
63
+ * @private
64
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/API/Notification/permission|Notification.permission}
65
+ * @see {@link Mocha#growl}
66
+ * @see {@link Mocha#isGrowlPermitted}
67
+ * @returns {Promise<boolean>} promise determining if browser notification
68
+ * permissible when fulfilled.
69
+ */
70
+ function isPermitted() {
71
+ var permitted = {
72
+ granted: function allow() {
73
+ return Promise.resolve(true);
74
+ },
75
+ denied: function deny() {
76
+ return Promise.resolve(false);
77
+ },
78
+ default: function ask() {
79
+ return Notification.requestPermission().then(function(permission) {
80
+ return permission === 'granted';
81
+ });
82
+ }
83
+ };
84
+
85
+ return permitted[Notification.permission]();
86
+ }
87
+
88
+ /**
89
+ * @summary
90
+ * Determines if notification should proceed.
91
+ *
92
+ * @description
93
+ * Notification shall <strong>not</strong> proceed unless `value` is true.
94
+ *
95
+ * `value` will equal one of:
96
+ * <ul>
97
+ * <li><code>true</code> (from `isPermitted`)</li>
98
+ * <li><code>false</code> (from `isPermitted`)</li>
99
+ * <li><code>undefined</code> (from `Promise.race`)</li>
100
+ * </ul>
101
+ *
102
+ * @private
103
+ * @param {boolean|undefined} value - Determines if notification permissible.
104
+ * @returns {Promise<undefined>} Notification can proceed
105
+ */
106
+ function canNotify(value) {
107
+ if (!value) {
108
+ var why = value === false ? 'blocked' : 'unacknowledged';
109
+ var reason = 'not permitted by user (' + why + ')';
110
+ return Promise.reject(new Error(reason));
111
+ }
112
+ return Promise.resolve();
113
+ }
114
+
115
+ /**
116
+ * Displays the notification.
117
+ *
118
+ * @private
119
+ * @param {Runner} runner - Runner instance.
120
+ */
121
+ function display(runner) {
122
+ var stats = runner.stats;
123
+ var symbol = {
124
+ cross: '\u274C',
125
+ tick: '\u2705'
126
+ };
127
+ var logo = require('../../package').notifyLogo;
128
+ var _message;
129
+ var message;
130
+ var title;
131
+
132
+ if (stats.failures) {
133
+ _message = stats.failures + ' of ' + stats.tests + ' tests failed';
134
+ message = symbol.cross + ' ' + _message;
135
+ title = 'Failed';
136
+ } else {
137
+ _message = stats.passes + ' tests passed in ' + stats.duration + 'ms';
138
+ message = symbol.tick + ' ' + _message;
139
+ title = 'Passed';
140
+ }
141
+
142
+ // Send notification
143
+ var options = {
144
+ badge: logo,
145
+ body: message,
146
+ dir: 'ltr',
147
+ icon: logo,
148
+ lang: 'en-US',
149
+ name: 'mocha',
150
+ requireInteraction: false,
151
+ timestamp: Date.now()
152
+ };
153
+ var notification = new Notification(title, options);
154
+
155
+ // Autoclose after brief delay (makes various browsers act same)
156
+ var FORCE_DURATION = 4000;
157
+ setTimeout(notification.close.bind(notification), FORCE_DURATION);
158
+ }
159
+
160
+ /**
161
+ * As notifications are tangential to our purpose, just log the error.
162
+ *
163
+ * @private
164
+ * @param {Error} err - Why notification didn't happen.
165
+ */
166
+ function notPermitted(err) {
167
+ console.error('notification error:', err.message);
168
+ }
@@ -9,7 +9,7 @@ module.exports = Progress;
9
9
  /**
10
10
  * Initialize a new `Progress` indicator.
11
11
  */
12
- function Progress () {
12
+ function Progress() {
13
13
  this.percent = 0;
14
14
  this.size(0);
15
15
  this.fontSize(11);
@@ -19,11 +19,11 @@ function Progress () {
19
19
  /**
20
20
  * Set progress size to `size`.
21
21
  *
22
- * @api public
22
+ * @public
23
23
  * @param {number} size
24
24
  * @return {Progress} Progress instance.
25
25
  */
26
- Progress.prototype.size = function (size) {
26
+ Progress.prototype.size = function(size) {
27
27
  this._size = size;
28
28
  return this;
29
29
  };
@@ -31,11 +31,11 @@ Progress.prototype.size = function (size) {
31
31
  /**
32
32
  * Set text to `text`.
33
33
  *
34
- * @api public
34
+ * @public
35
35
  * @param {string} text
36
36
  * @return {Progress} Progress instance.
37
37
  */
38
- Progress.prototype.text = function (text) {
38
+ Progress.prototype.text = function(text) {
39
39
  this._text = text;
40
40
  return this;
41
41
  };
@@ -43,11 +43,11 @@ Progress.prototype.text = function (text) {
43
43
  /**
44
44
  * Set font size to `size`.
45
45
  *
46
- * @api public
46
+ * @public
47
47
  * @param {number} size
48
48
  * @return {Progress} Progress instance.
49
49
  */
50
- Progress.prototype.fontSize = function (size) {
50
+ Progress.prototype.fontSize = function(size) {
51
51
  this._fontSize = size;
52
52
  return this;
53
53
  };
@@ -58,7 +58,7 @@ Progress.prototype.fontSize = function (size) {
58
58
  * @param {string} family
59
59
  * @return {Progress} Progress instance.
60
60
  */
61
- Progress.prototype.font = function (family) {
61
+ Progress.prototype.font = function(family) {
62
62
  this._font = family;
63
63
  return this;
64
64
  };
@@ -69,7 +69,7 @@ Progress.prototype.font = function (family) {
69
69
  * @param {number} n
70
70
  * @return {Progress} Progress instance.
71
71
  */
72
- Progress.prototype.update = function (n) {
72
+ Progress.prototype.update = function(n) {
73
73
  this.percent = n;
74
74
  return this;
75
75
  };
@@ -80,7 +80,7 @@ Progress.prototype.update = function (n) {
80
80
  * @param {CanvasRenderingContext2d} ctx
81
81
  * @return {Progress} Progress instance.
82
82
  */
83
- Progress.prototype.draw = function (ctx) {
83
+ Progress.prototype.draw = function(ctx) {
84
84
  try {
85
85
  var percent = Math.min(this.percent, 100);
86
86
  var size = this._size;
@@ -112,7 +112,7 @@ Progress.prototype.draw = function (ctx) {
112
112
  var w = ctx.measureText(text).width;
113
113
 
114
114
  ctx.fillText(text, x - w / 2 + 1, y + fontSize / 2 - 1);
115
- } catch (err) {
115
+ } catch (ignore) {
116
116
  // don't fail if we can't render progress
117
117
  }
118
118
  return this;
File without changes
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- exports.isatty = function isatty () {
3
+ exports.isatty = function isatty() {
4
4
  return true;
5
5
  };
6
6
 
7
- exports.getWindowSize = function getWindowSize () {
7
+ exports.getWindowSize = function getWindowSize() {
8
8
  if ('innerHeight' in global) {
9
9
  return [global.innerHeight, global.innerWidth];
10
10
  }