|
1 | 1 | import { existsSync } from 'node:fs'; |
2 | 2 | import { readFile, realpath, writeFile } from 'node:fs/promises'; |
3 | | -import { EOL } from 'node:os'; |
4 | 3 | import path from 'node:path'; |
5 | | -import toml, { Section } from '@ltd/j-toml'; |
6 | 4 | import detectIndent from 'detect-indent'; |
7 | 5 | import parseJson from 'parse-json'; |
| 6 | +import toml from 'smol-toml'; |
8 | 7 | import yaml from 'yaml'; |
9 | 8 | import type { |
10 | 9 | ConfigFile, |
@@ -64,9 +63,7 @@ async function getConfigFile(folderPath: string): Promise< |
64 | 63 | let data: ConfigFile; |
65 | 64 | let format: 'toml' | 'yml' | 'json'; |
66 | 65 | if (config.path.endsWith('.toml')) { |
67 | | - data = toml.parse(config.data, { |
68 | | - joiner: EOL, |
69 | | - }) as ConfigFile; |
| 66 | + data = toml.parse(config.data) as ConfigFile; |
70 | 67 | format = 'toml'; |
71 | 68 | } else if ( |
72 | 69 | config.path.endsWith('.yml') || |
@@ -158,21 +155,7 @@ export async function writeConfig({ |
158 | 155 | }) { |
159 | 156 | const indent = configFileSettings.indent; |
160 | 157 | const stringify = { |
161 | | - toml: (configFile: ConfigFile) => { |
162 | | - for (const key of Object.keys(configFile.vendorDependencies)) { |
163 | | - if (configFile.vendorDependencies[key]) { |
164 | | - configFile.vendorDependencies[key] = Section( |
165 | | - configFile.vendorDependencies[key], |
166 | | - ); |
167 | | - } |
168 | | - } |
169 | | - // @ts-expect-error toml doesn't understand that the ConfigFile type is just an object |
170 | | - return toml.stringify(configFile, { |
171 | | - newline: EOL, |
172 | | - indent, |
173 | | - newlineAround: 'section', |
174 | | - }); |
175 | | - }, |
| 158 | + toml: (configFile: ConfigFile) => toml.stringify(configFile), |
176 | 159 | yml: (configFile: ConfigFile) => |
177 | 160 | yaml.stringify(configFile, { |
178 | 161 | indent: typeof indent === 'number' ? indent : indent?.length, |
|
0 commit comments