Unvendor toml package (#1263)

* Unvendor toml package

* Try @iarna/toml instead

* Fix import

* Use @ltd/j-toml

* Update test

* Use toml-j0.4

* Fix toml import
This commit is contained in:
Hood Chatham
2023-03-09 10:06:43 +01:00
committed by GitHub
parent 41a8d804e3
commit 84e4e361c5
5 changed files with 23 additions and 1795 deletions

View File

@@ -1,4 +1,4 @@
import toml from '../src/toml';
import toml from 'toml-j0.4';
import { getLogger } from './logger';
import { version } from './version';
import { getAttribute, readTextFromPath, htmlDecode, createDeprecationWarning } from './utils';
@@ -145,17 +145,18 @@ function mergeConfig(inlineConfig: AppConfig, externalConfig: AppConfig): AppCon
function parseConfig(configText: string, configType = 'toml') {
if (configType === 'toml') {
// TOML parser is soft and can parse even JSON strings, this additional check prevents it.
if (configText.trim()[0] === '{') {
throw new UserError(
ErrorCode.BAD_CONFIG,
`The config supplied: ${configText} is an invalid TOML and cannot be parsed`,
);
}
try {
// TOML parser is soft and can parse even JSON strings, this additional check prevents it.
if (configText.trim()[0] === '{') {
throw new UserError(
ErrorCode.BAD_CONFIG,
`The config supplied: ${configText} is an invalid TOML and cannot be parsed`,
);
}
return toml.parse(configText);
} catch (err) {
const errMessage: string = err.toString();
throw new UserError(
ErrorCode.BAD_CONFIG,
`The config supplied: ${configText} is an invalid TOML and cannot be parsed: ${errMessage}`,

File diff suppressed because it is too large Load Diff