Skip to content

Commit

Permalink
Replace print with serialize in ConvertAnsi plugin (#4225)
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrottimark authored and cpojer committed Aug 9, 2017
1 parent ce768d0 commit 59e7ee2
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions packages/pretty-format/src/plugins/convert_ansi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,7 @@
* @flow
*/

import type {
Colors,
Indent,
PluginOptions,
Print,
Plugin,
} from 'types/PrettyFormat';
import type {Config, Printer, NewPlugin, Refs} from 'types/PrettyFormat';

import ansiRegex from 'ansi-regex';
import style from 'ansi-styles';
Expand All @@ -41,15 +35,16 @@ const toHumanReadableAnsi = text => {
});
};

export const test = (value: any) =>
typeof value === 'string' && value.match(ansiRegex());
export const test = (val: any) =>
typeof val === 'string' && val.match(ansiRegex());

export const print = (
val: any,
print: Print,
indent: Indent,
opts: PluginOptions,
colors: Colors,
) => print(toHumanReadableAnsi(val));
export const serialize = (
val: string,
config: Config,
indentation: string,
depth: number,
refs: Refs,
printer: Printer,
) => printer(toHumanReadableAnsi(val), config, indentation, depth, refs);

export default ({print, test}: Plugin);
export default ({serialize, test}: NewPlugin);

0 comments on commit 59e7ee2

Please sign in to comment.