all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-eslint] switch to using `Command.opts()` to access options
@ 2023-08-30  9:24 Stefan Sterz
  2023-08-30  9:39 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Sterz @ 2023-08-30  9:24 UTC (permalink / raw)
  To: pve-devel

this fixes an issue  where the options where not properly passed to
eslint, which rendered them useless. uses the `opts()` function to
access them. see [1] for more on info on option parsing with
commander.

[1]: https://www.npmjs.com/package/commander#user-content-options

Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
---

not sure how we handle this, but might need a:

Reported-by: Max Carrara <m.carrara@proxmox.com>

 src/bin/app.js | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/bin/app.js b/src/bin/app.js
index 48ae043..7d0088f 100644
--- a/src/bin/app.js
+++ b/src/bin/app.js
@@ -27,13 +27,14 @@ program.on('--help', function() {
 });
 
 program.parse(process.argv);
+let options = program.opts();
 
-if (program.config && program.extend) {
+if (options.config && options.extend) {
     console.error('Cannot use both, --config and --extend, at the same time!');
     process.exit(1);
 }
 
-if (program.args.length < 1 && !program.outputConfig) {
+if (program.args.length < 1 && !options.outputConfig) {
     program.help();
 }
 
@@ -44,8 +45,8 @@ if (!paths.length) {
 }
 
 let threadCount = 4;
-if (program.threads) {
-    threadCount = program.threads;
+if (options.threads) {
+    threadCount = options.threads;
 }
 
 const defaultConfig = {
@@ -274,16 +275,16 @@ let pathExpand = (p) => {
 };
 
 let config = defaultConfig;
-if (program.config) {
+if (options.config) {
     config = {
-	"extends": pathExpand(program.config),
+	"extends": pathExpand(options.config),
     };
-} else if (program.extend) {
-    config.extends = pathExpand(program.extend);
+} else if (options.extend) {
+    config.extends = pathExpand(options.extend);
     console.log(`Extend with path: ${config.extends}`);
 }
 
-if (program.outputConfig) {
+if (options.outputConfig) {
     let cfg = JSON.stringify(config, null, 2);
     console.log(cfg);
     process.exit(0);
@@ -292,7 +293,7 @@ if (program.outputConfig) {
 const cliOptions = {
     baseConfig: config,
     useEslintrc: true,
-    fix: !!program.fix,
+    fix: !!options.fix,
     cwd: process.cwd(),
 };
 
@@ -322,7 +323,7 @@ results.forEach(function(result) {
     let filename = path.relative(process.cwd(), result.filePath);
     let msgs = result.messages;
     let max_sev = 0;
-    if (!!program.fix && result.output) {
+    if (!!options.fix && result.output) {
 	fixes++;
     }
     if (msgs.length <= 0) {
@@ -337,7 +338,7 @@ results.forEach(function(result) {
 	let msg = `: line ${color.bold(e.line)} col ${color.bold(e.column)}: ${e.ruleId}`;
 	if (e.severity === 1) {
 	    msg = color.yellow("WARN" + msg);
-	    if (exitcode < 1 && !!program.strict) {
+	    if (exitcode < 1 && !!options.strict) {
 		exitcode = 1;
 	    }
 	} else if (e.severity === 2) {
@@ -351,7 +352,7 @@ results.forEach(function(result) {
 	if (e.message) {
 	    msg += ` - ${e.message}`;
 	}
-	if (!program.fix && e.fix) {
+	if (!options.fix && e.fix) {
 	    fixes++;
 	    msg += ' (*)';
 	}
@@ -386,7 +387,7 @@ if (results.length > 1) {
 }
 console.log('------------------------------------------------------------');
 
-if (program.fix) {
+if (options.fix) {
     if (fixes > 0) {
 	console.log(`Writing ${color.bold(fixes)} fixed files...`);
 	await eslint.ESLint.outputFixes(results);
-- 
2.39.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pve-devel] applied: [PATCH pve-eslint] switch to using `Command.opts()` to access options
  2023-08-30  9:24 [pve-devel] [PATCH pve-eslint] switch to using `Command.opts()` to access options Stefan Sterz
@ 2023-08-30  9:39 ` Thomas Lamprecht
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Lamprecht @ 2023-08-30  9:39 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stefan Sterz

Am 30/08/2023 um 11:24 schrieb Stefan Sterz:
> this fixes an issue  where the options where not properly passed to
> eslint, which rendered them useless. uses the `opts()` function to
> access them. see [1] for more on info on option parsing with
> commander.
> 
> [1]: https://www.npmjs.com/package/commander#user-content-options
> 
> Signed-off-by: Stefan Sterz <s.sterz@proxmox.com>
> ---
> 
> not sure how we handle this, but might need a:
> 
> Reported-by: Max Carrara <m.carrara@proxmox.com>
> 
>  src/bin/app.js | 29 +++++++++++++++--------------
>  1 file changed, 15 insertions(+), 14 deletions(-)
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-08-30  9:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-30  9:24 [pve-devel] [PATCH pve-eslint] switch to using `Command.opts()` to access options Stefan Sterz
2023-08-30  9:39 ` [pve-devel] applied: " Thomas Lamprecht

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal