From: =?utf-8?q?Bastien_Roucari=C3=A8s?= Date: Mon, 12 Aug 2024 19:36:03 +0000 Subject: Use has-flag instead to use copy/paste forwareded: not-needed --- index.js | 9 +-------- package.json | 3 +++ 2 files changed, 4 insertions(+), 8 deletions(-) --- a/index.js +++ b/index.js @@ -2,14 +2,7 @@ import os from 'node:os'; import tty from 'node:tty'; -// From: https://github.com/sindresorhus/has-flag/blob/main/index.js -/// function hasFlag(flag, argv = globalThis.Deno?.args ?? process.argv) { -function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : process.argv) { - const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--'); - const position = argv.indexOf(prefix + flag); - const terminatorPosition = argv.indexOf('--'); - return position !== -1 && (terminatorPosition === -1 || position < terminatorPosition); -} +import hasFlag from 'has-flag'; const {env} = process; --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ "engines": { "node": ">=18" }, + "dependencies": { + "has-flag": "^5.0.0" + }, "scripts": { "test": "xo && ava && tsd" },