From b21018deae9ec75f6a2d1ecbfd971d3978cc694e Mon Sep 17 00:00:00 2001 From: Yanis Benson Date: Mon, 22 Jul 2019 03:47:32 +0300 Subject: [PATCH] lazy load templates --- source/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/index.js b/source/index.js index 90a6348..770724b 100644 --- a/source/index.js +++ b/source/index.js @@ -1,7 +1,6 @@ 'use strict'; const ansiStyles = require('ansi-styles'); const {stdout: stdoutColor, stderr: stderrColor} = require('supports-color'); -const template = require('./templates'); const { stringReplaceAll, stringEncaseCRLFWithFirstIndex @@ -185,6 +184,7 @@ const applyStyle = (self, string) => { return openAll + string + closeAll; }; +let template; const chalkTag = (chalk, ...strings) => { const [firstString] = strings; @@ -204,6 +204,9 @@ const chalkTag = (chalk, ...strings) => { ); } + if (template === undefined) { + template = require('./templates'); + } return template(chalk, parts.join('')); };