Skip to content

Commit

Permalink
fix: Filter empty strings out of list options (#1483)
Browse files Browse the repository at this point in the history
* fix: Filter empty strings out of list options

* chore: Clarify what split function does
  • Loading branch information
ValeriaVG committed Oct 6, 2021
1 parent a28d69a commit 1660ed1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
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

0 comments on commit 1660ed1

Please sign in to comment.