diff --git a/src/cli.ts b/src/cli.ts index 9ea568056b..855c4df226 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -217,7 +217,6 @@ export function injectGlobalRequire(origin: string) { } export function transformMarkdown(buf: Buffer | string): string { - const source = buf.toString() const output = [] const tabRe = /^( +|\t)/ const codeBlockRe = @@ -225,7 +224,7 @@ export function transformMarkdown(buf: Buffer | string): string { let state = 'root' let codeBlockEnd = '' let prevLineIsEmpty = true - for (const line of source.split(/\r?\n/)) { + for (const line of buf.toString().split(/\r?\n/)) { switch (state) { case 'root': if (tabRe.test(line) && prevLineIsEmpty) { diff --git a/src/util.ts b/src/util.ts index 9d7207f2b7..457d455712 100644 --- a/src/util.ts +++ b/src/util.ts @@ -277,23 +277,19 @@ export function formatCmd(cmd?: string): string { } function space() { - if (/\s/.test(ch)) return space - return root + return /\s/.test(ch) ? space : root } function word() { - if (/[\w/.]/i.test(ch)) return word - return root + return /[\w/.]/i.test(ch) ? word : root } function syntax() { - if (isSyntax(ch)) return syntax - return root + return isSyntax(ch) ? syntax : root } function dollar() { - if (ch === "'") return str - return root + return ch === "'" ? str : root } function str() { @@ -311,13 +307,11 @@ export function formatCmd(cmd?: string): string { } function strDouble() { - if (ch === '"') return strEnd - return strDouble + return ch === '"' ? strEnd : strDouble } function strSingle() { - if (ch === "'") return strEnd - return strSingle + return ch === "'" ? strEnd : strSingle } function strEnd() {