v8flags icon indicating copy to clipboard operation
v8flags copied to clipboard

Result includes `--flag`, which is not a valid flag

Open nicolo-ribaudo opened this issue 3 years ago • 2 comments

Before you open this issue, please complete the following tasks:

  • [x] use the search bar at the top of the page to search this repository for similar issues or discussions that have already been opened.
  • [ ] if you are looking for help from the gulp team or community, open a discussion.
  • [ ] if you think there is a problem with the plugin you're using, open a discussion.
  • [x] if you think there is a bug in our code, open this issue.

What were you expecting to happen?

--flag is not a valid flag, and thus it should not be reported.

node --v8-options includes --flag as an example:

The following syntax for options is accepted (both '-' and '--' are ok):
  --flag        (bool flags only)
  --no-flag     (bool flags only)
  --flag=value  (non-bool flags only, no spaces around '=')
  --flag value  (non-bool flags only)
  --            (captures all remaining args in JavaScript)

Options:
  --experimental (Indicates that V8 is running with experimental features enabled. This flag is typically not set explicitly but instead enabled as an implication of other flags which enable experimental features.)
        type: bool  default: --no-experimental
  --abort-on-contradictory-flags (Disallow flags or implications overriding each other.)
        type: bool  default: --no-abort-on-contradictory-flags
  --exit-on-contradictory-flags (Exit with return code 0 on contradictory flags.)
        type: bool  default: --no-exit-on-contradictory-flags
  --allow-overwriting-for-next-flag (temporary disable flag contradiction to allow overwriting just the next flag)
        type: bool  default: --no-allow-overwriting-for-next-flag
  ...

It looks like there is some logic to skip it, but it's not working: https://github.com/gulpjs/v8flags/blob/1f70fd1ce962dbf426a5fd17c7637248fc71c200/index.js#L95

What actually happened?

--flag is included

Please give us a sample of your gulpfile

var v8flags = require("v8flags");
var fs = require("fs");
fs.rmSync(v8flags.configPath, { recursive: true });

v8flags((err, res) => {
  console.assert(!res.includes("--flag"));
});

Terminal output / screenshots

$ node demo1.js
Assertion failed

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: MacOS
  • node version (run node -v): v20.5.1
  • npm version (run npm -v):
  • gulp version (run gulp -v):

Additional information

I am trying to upgrade to v4.0.0 in Babel: babel/babel#15908

nicolo-ribaudo avatar Aug 30 '23 15:08 nicolo-ribaudo

@nicolo-ribaudo Thank you for your report. As you said, regexp.lastIndex = index; is not effective for String#match(regexp);. I'll replace this line to result = result.slice(index); instread.

sttk avatar Sep 02 '23 05:09 sttk

@nicolo-ribaudo Since you are using this in babel, can you please add a comment to https://github.com/nodejs/node/pull/40791 - @trott was trying to get this upstreamed into nodejs and having another large project like babel needing the API would help!

phated avatar Sep 03 '23 22:09 phated