Skip to content

Commit 24d7acc

Browse files
authored
Create consistent property type and avoid polymorphic values (#428)
1 parent 42d5e1b commit 24d7acc

30 files changed

+68
-67
lines changed

src/commands/analytics/cmd-analytics.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,14 @@ async function run(
106106
},
107107
{
108108
nook: true,
109-
test: scope === 'org' || repo,
109+
test: scope === 'org' || !!repo,
110110
message: 'When scope=repo, repo name should be set through --repo',
111111
pass: 'ok',
112112
fail: 'missing'
113113
},
114114
{
115115
nook: true,
116-
test: file === '-' || json || markdown,
116+
test: file === '-' || !!json || !!markdown,
117117
message:
118118
'The `--file` flag is only valid when using `--json` or `--markdown`',
119119
pass: 'ok',
@@ -129,7 +129,7 @@ async function run(
129129
},
130130
{
131131
nook: true,
132-
test: apiToken,
132+
test: !!apiToken,
133133
message:
134134
'You need to be logged in to use this command. See `socket login`.',
135135
pass: 'ok',

src/commands/audit-log/cmd-audit-log.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ async function run(
8686

8787
const wasBadInput = handleBadInput(
8888
{
89-
test: orgSlug,
89+
test: !!orgSlug,
9090
message: 'Org name should be the first arg',
9191
pass: 'ok',
9292
fail: 'missing'
9393
},
9494
{
9595
nook: true,
96-
test: apiToken,
96+
test: !!apiToken,
9797
message:
9898
'You need to be logged in to use this command. See `socket login`.',
9999
pass: 'ok',

src/commands/config/cmd-config-set.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,13 @@ async function run(
6868

6969
const wasBadInput = handleBadInput(
7070
{
71-
test: supportedConfigKeys.has(key as keyof LocalConfig) || key === 'test',
71+
test: key === 'test' || supportedConfigKeys.has(key as keyof LocalConfig),
7272
message: 'Config key should be the first arg',
7373
pass: 'ok',
7474
fail: key ? 'invalid config key' : 'missing'
7575
},
7676
{
77-
test: value, // This is a string, empty string is not ok
77+
test: !!value, // This is a string, empty string is not ok
7878
message:
7979
'Key value should be the remaining args (use `unset` to unset a value)',
8080
pass: 'ok',

src/commands/config/cmd-config-unset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function run(
6262

6363
const wasBadInput = handleBadInput(
6464
{
65-
test: supportedConfigKeys.has(key as keyof LocalConfig) || key === 'test',
65+
test: key === 'test' || supportedConfigKeys.has(key as keyof LocalConfig),
6666
message: 'Config key should be the first arg',
6767
pass: 'ok',
6868
fail: key ? 'invalid config key' : 'missing'

src/commands/dependencies/cmd-dependencies.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async function run(
8282
},
8383
{
8484
nook: true,
85-
test: apiToken,
85+
test: !!apiToken,
8686
message:
8787
'You need to be logged in to use this command. See `socket login`.',
8888
pass: 'ok',

src/commands/diff-scan/cmd-diff-scan-get.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async function run(
127127
},
128128
{
129129
nook: true,
130-
test: apiToken,
130+
test: !!apiToken,
131131
message:
132132
'You need to be logged in to use this command. See `socket login`.',
133133
pass: 'ok',

src/commands/info/cmd-info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ async function run(
5858

5959
const wasBadInput = handleBadInput(
6060
{
61-
test: rawPkgName,
61+
test: !!rawPkgName,
6262
message: 'Expecting a package name',
6363
pass: 'ok',
6464
fail: 'missing'

src/commands/manifest/cmd-manifest-gradle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ async function run(
124124

125125
const wasBadInput = handleBadInput(
126126
{
127-
test: target && target !== '-',
127+
test: !!target && target !== '-',
128128
message: 'The DIR arg is required',
129129
pass: 'ok',
130130
fail: target === '-' ? 'stdin is not supported' : 'missing'

src/commands/manifest/cmd-manifest-kotlin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ async function run(
129129

130130
const wasBadInput = handleBadInput(
131131
{
132-
test: target && target !== '-',
132+
test: !!target && target !== '-',
133133
message: 'The DIR arg is required',
134134
pass: 'ok',
135135
fail: target === '-' ? 'stdin is not supported' : 'missing'

src/commands/manifest/cmd-manifest-scala.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ async function run(
122122

123123
const wasBadInput = handleBadInput(
124124
{
125-
test: target && target !== '-',
125+
test: !!target && target !== '-',
126126
message: 'The DIR arg is required',
127127
pass: 'ok',
128128
fail: target === '-' ? 'stdin is not supported' : 'missing'

0 commit comments

Comments
 (0)