Skip to content

Commit eb14aeb

Browse files
authored
Merge pull request #2080 from github/henrymercer/fix-unconditional-warning
Fix `paths`/`paths-ignore` warning that would appear unconditionally
2 parents cd94990 + 30597e3 commit eb14aeb

File tree

6 files changed

+71
-7
lines changed

6 files changed

+71
-7
lines changed

lib/init.js

+4-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init.test.js

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/init.test.js.map

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/init.test.ts

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import test from "ava";
2+
3+
import { Config } from "./config-utils";
4+
import { printPathFiltersWarning } from "./init";
5+
import { Language } from "./languages";
6+
import { LoggedMessage, getRecordingLogger, setupTests } from "./testing-utils";
7+
8+
setupTests(test);
9+
10+
test("printPathFiltersWarning does not trigger when 'paths' and 'paths-ignore' are undefined", async (t) => {
11+
const messages: LoggedMessage[] = [];
12+
printPathFiltersWarning(
13+
{
14+
languages: [Language.cpp],
15+
originalUserInput: {},
16+
} as Partial<Config> as Config,
17+
getRecordingLogger(messages),
18+
);
19+
t.is(messages.length, 0);
20+
});
21+
22+
test("printPathFiltersWarning does not trigger when 'paths' and 'paths-ignore' are empty", async (t) => {
23+
const messages: LoggedMessage[] = [];
24+
printPathFiltersWarning(
25+
{
26+
languages: [Language.cpp],
27+
originalUserInput: { paths: [], "paths-ignore": [] },
28+
} as Partial<Config> as Config,
29+
getRecordingLogger(messages),
30+
);
31+
t.is(messages.length, 0);
32+
});

src/init.ts

+6-3
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ export async function runInit(
127127
return await getCombinedTracerConfig(config);
128128
}
129129

130-
function printPathFiltersWarning(config: configUtils.Config, logger: Logger) {
130+
export function printPathFiltersWarning(
131+
config: configUtils.Config,
132+
logger: Logger,
133+
) {
131134
// Index include/exclude/filters only work in javascript/python/ruby.
132135
// If any other languages are detected/configured then show a warning.
133136
if (
134-
(config.originalUserInput.paths?.length !== 0 ||
135-
config.originalUserInput["paths-ignore"]?.length !== 0) &&
137+
(config.originalUserInput.paths?.length ||
138+
config.originalUserInput["paths-ignore"]?.length) &&
136139
!config.languages.every(isScannedLanguage)
137140
) {
138141
logger.warning(

0 commit comments

Comments
 (0)