From 58f009a2a69365abc2d3af187ef0abdc9e4f5297 Mon Sep 17 00:00:00 2001 From: Takayuki Sato Date: Mon, 4 Sep 2023 07:45:45 +0900 Subject: [PATCH] fix: Exclude example flags provided by node (#66) Co-authored-by: Blaine Bublitz --- index.js | 2 +- test/index.js | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index ac38f51..d5c0e24 100644 --- a/index.js +++ b/index.js @@ -91,8 +91,8 @@ function getFlags(cb) { var index = result.indexOf('\nOptions:'); if (index >= 0) { + result = result.slice(index); var regexp = /^\s\s--[\w-]+/gm; - regexp.lastIndex = index; var matchedFlags = result.match(regexp); if (matchedFlags) { flags = flags.concat( diff --git a/test/index.js b/test/index.js index 75b8acf..8e39b09 100644 --- a/test/index.js +++ b/test/index.js @@ -225,6 +225,16 @@ describe('v8flags', function () { done(); }); }); + + it('does not detect nodejs example flags', function (done) { + eraseHome(); + var v8flags = require('../'); + v8flags(function (err, flags) { + expect(flags).not.toContain('--flag'); + expect(flags).not.toContain('--no-flag'); + done(); + }); + }); }); describe('config-path', function () {