From 3387f8f656c8212bdd82f7599af46c38532313d9 Mon Sep 17 00:00:00 2001 From: Paulo Castro Date: Wed, 5 Jun 2019 16:12:16 +0100 Subject: [PATCH] Fix 'npm help' SyntaxError on Node 8 (invalid 's' regex flag) Change-type: patch Signed-off-by: Paulo Castro --- lib/actions/help_ts.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/actions/help_ts.ts b/lib/actions/help_ts.ts index 172e7550..aaf30ea9 100644 --- a/lib/actions/help_ts.ts +++ b/lib/actions/help_ts.ts @@ -27,7 +27,9 @@ export function getOclifHelpLinePairs(): [[string, string]] { function getCmdUsageDescriptionLinePair(cmd: typeof Command): [string, string] { const usage = (cmd.usage || '').toString().toLowerCase(); let description = ''; - const matches = /\s*(.+?)\n.*/s.exec(cmd.description || ''); + // note: [^] matches any characters (including line breaks), achieving the + // same effect as the 's' regex flag which is only supported by Node 9+ + const matches = /\s*([^]+?)\n[^]*/.exec(cmd.description || ''); if (matches && matches.length > 1) { description = _.lowerFirst(_.trimEnd(matches[1], '.')); }