Skip to content
This repository was archived by the owner on Jul 9, 2021. It is now read-only.

Commit e0e7a60

Browse files
committed
[added] function logSequentialSuccessMessage to the logger module
1 parent 1e86281 commit e0e7a60

4 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/Compiler.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ import mkdirp from 'mkdirp';
55
import {dirname} from 'path';
66
import {writeFile, readFile} from 'fs';
77
import {gzip, gunzip} from 'zlib';
8-
import {logError, log, consoleStyles} from './logger';
98
import {isProduction} from './webpack';
10-
11-
/* eslint-disable no-process-env */
12-
13-
const {green} = consoleStyles;
14-
15-
let i = 0;
9+
import {logError, logSequentialSuccessMessage} from './logger';
1610

1711
/**
1812
* The base compiler class
@@ -49,7 +43,7 @@ export class Compiler {
4943
* @param {Function} callback - a callback function
5044
*/
5145
static done(inPath: string, callback: () => void) {
52-
log(green(++i, '. Compiled ', inPath));
46+
logSequentialSuccessMessage(`Compiled ${inPath}`);
5347
callback();
5448
}
5549

src/Documentation.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import type {NativeProcess} from './NativeProcess';
44
import {join} from 'path';
55
import noop from 'lodash/noop';
6-
import {logError} from './logger';
6+
import {logError, logSequentialSuccessMessage} from './logger';
77
import {findBinary} from './findBinary';
88
import {watch} from './watch';
99
import tinylr from 'tiny-lr';
@@ -81,6 +81,7 @@ export class Documentation {
8181
if (stderr) {
8282
return logError(stderr);
8383
}
84+
logSequentialSuccessMessage(`Generated API documentation for ${inputDir}`);
8485
callback();
8586
}, [inputDir, '-d', outputDir, '-R', readMe, '-c', jsdocConfig, '-t', template]);
8687
});

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ export {Documentation} from './Documentation';
66
export {watch} from './watch';
77
export {yaml} from './yaml';
88
export {findBinary} from './findBinary';
9-
export {consoleStyles, log, logError, logPostCSSWarnings, logSASSError, logLintingErrors} from './logger';
109
export {babelBEOptions, babelFEOptions} from './webpack';
10+
export {consoleStyles, log, logError, logPostCSSWarnings, logSASSError, logLintingErrors,
11+
logSequentialSuccessMessage} from './logger';
1112

1213
export {flatten, arrayToJSX, htmlToArray, htmlToJSX} from './jsx';
1314
export {markdownToArray, markdownToJSX, markdownToHTML} from './markdown';

src/logger.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import cleanStack from 'clean-stack';
99

1010
/* eslint-disable no-console */
1111

12+
let i = 0;
13+
1214
/**
1315
* Dead-simple, composable, isomorphic, cross-browser wrapper for `console.log`.
1416
*
@@ -405,3 +407,22 @@ export function logLintingErrors(errors: LintError[], prefix: ?string = null) {
405407
});
406408
log(prefix ? `${prefix} l` : 'L', 'inting errors: ', errors.length);
407409
}
410+
411+
/**
412+
* Within the current process logs green colored messages out to the console prepending a sequential a number starting
413+
* with "1." to the message, to make it easier to distinguish messages containing the same text.
414+
*
415+
* @memberof module:logger
416+
* @function logSequentialSuccessMessage
417+
* @param {string} message - a message to log
418+
* @example
419+
* import {logSequentialSuccessMessage} from 'webcompiler';
420+
* // or - import {logSequentialSuccessMessage} from 'webcompiler/lib/logger';
421+
* // or - var logSequentialSuccessMessage = require('webcompiler').logSequentialSuccessMessage;
422+
* // or - var logSequentialSuccessMessage = require('webcompiler/lib/logger').logSequentialSuccessMessage;
423+
*/
424+
export function logSequentialSuccessMessage(message: string) {
425+
const {green} = consoleStyles;
426+
427+
log(green(++i, '. ', message));
428+
}

0 commit comments

Comments
 (0)