File: 0003-Use-has-flag-instead-to-use-copy-paste.patch

package info (click to toggle)
node-supports-color 10.2.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 176 kB
  • sloc: javascript: 699; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,137 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
From: =?utf-8?q?Bastien_Roucari=C3=A8s?= <rouca@debian.org>
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"
 	},