Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Filter empty strings out of list options #1483

Merged
merged 2 commits into from Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/test/index.spec.ts
Expand Up @@ -602,6 +602,21 @@ test.suite('ts-node', (test) => {
]);
});

test('should ignore empty strings in the array options', async () => {
const { err, stdout } = await exec(
`${BIN_EXEC} tsconfig-options/log-options1.js`,
{
env: {
...process.env,
TS_NODE_IGNORE: '',
},
}
);
expect(err).toBe(null);
const { options } = JSON.parse(stdout);
expect(options.ignore).toEqual([]);
});

test('should have flags override / merge with `tsconfig.json`', async () => {
const { err, stdout } = await exec(
`${BIN_EXEC} --skip-ignore --compiler-options "{\\"types\\":[\\"flags-types\\"]}" --require ./tsconfig-options/required2.js tsconfig-options/log-options2.js`
Expand Down
7 changes: 5 additions & 2 deletions src/util.ts
Expand Up @@ -39,11 +39,14 @@ export function assign<T extends object>(
}

/**
* Split a string array of values.
* Split a string array of values
* and remove empty strings from the resulting array.
* @internal
*/
export function split(value: string | undefined) {
return typeof value === 'string' ? value.split(/ *, */g) : undefined;
return typeof value === 'string'
? value.split(/ *, */g).filter((v) => v !== '')
: undefined;
}

/**
Expand Down