Skip to content

Commit 27832dc

Browse files
authored
Merge pull request #109 from Araxeus/replace-@ltd/j-toml-with-smol-toml
2 parents 88d0deb + 70b88ac commit 27832dc

File tree

4 files changed

+6
-25
lines changed

4 files changed

+6
-25
lines changed

bun.lockb

-8 Bytes
Binary file not shown.

lib/commands.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,13 +150,11 @@ export async function uninstall(
150150
}
151151
} else if (lockfile?.[name]) {
152152
// if not, remove the dependency from the lockfile
153-
// @ts-expect-error Type 'undefined' is not assignable to type 'VendorLock'
154-
lockfile[name] = undefined;
153+
delete lockfile[name];
155154
await fs.writeFile(lockfilePath, JSON.stringify(lockfile, null, 2));
156155
}
157156

158-
// @ts-expect-error Type 'undefined' is not assignable to type 'VendorDependency'
159-
configFile.vendorDependencies[name] = undefined;
157+
delete configFile.vendorDependencies[name];
160158

161159
await writeConfig({
162160
configFile,

lib/config.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { existsSync } from 'node:fs';
22
import { readFile, realpath, writeFile } from 'node:fs/promises';
3-
import { EOL } from 'node:os';
43
import path from 'node:path';
5-
import toml, { Section } from '@ltd/j-toml';
64
import detectIndent from 'detect-indent';
75
import parseJson from 'parse-json';
6+
import toml from 'smol-toml';
87
import yaml from 'yaml';
98
import type {
109
ConfigFile,
@@ -64,9 +63,7 @@ async function getConfigFile(folderPath: string): Promise<
6463
let data: ConfigFile;
6564
let format: 'toml' | 'yml' | 'json';
6665
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;
7067
format = 'toml';
7168
} else if (
7269
config.path.endsWith('.yml') ||
@@ -158,21 +155,7 @@ export async function writeConfig({
158155
}) {
159156
const indent = configFileSettings.indent;
160157
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),
176159
yml: (configFile: ConfigFile) =>
177160
yaml.stringify(configFile, {
178161
indent: typeof indent === 'number' ? indent : indent?.length,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
},
4040
"dependencies": {
4141
"@commander-js/extra-typings": "^14.0.0",
42-
"@ltd/j-toml": "^1.38.0",
4342
"@octokit/auth-oauth-device": "^8.0.3",
4443
"@octokit/rest": "^22.0.1",
4544
"commander": "^14.0.2",
@@ -49,6 +48,7 @@
4948
"make-fetch-happen": "^15.0.3",
5049
"open": "^11.0.0",
5150
"parse-json": "^8.3.0",
51+
"smol-toml": "^1.5.2",
5252
"unarchive": "^1.1.4",
5353
"yaml": "^2.8.1"
5454
},

0 commit comments

Comments
 (0)