chore: Prettier fix formatting
This commit is contained in:
1 parent
9de7253998
commit
25cd7cc8e2
106 files changed
+1624
-5278
No files matched your search
+4
-8
@@ -10,19 +10,15 @@ export function calculateApiCost(
|
||||
const modelCacheWritesPrice = modelInfo.cacheWritesPrice
|
||||
let cacheWritesCost = 0
|
||||
if (cacheCreationInputTokens && modelCacheWritesPrice) {
|
||||
cacheWritesCost =
|
||||
(modelCacheWritesPrice / 1_000_000) * cacheCreationInputTokens
|
||||
cacheWritesCost = (modelCacheWritesPrice / 1_000_000) * cacheCreationInputTokens
|
||||
}
|
||||
const modelCacheReadsPrice = modelInfo.cacheReadsPrice
|
||||
let cacheReadsCost = 0
|
||||
if (cacheReadInputTokens && modelCacheReadsPrice) {
|
||||
cacheReadsCost =
|
||||
(modelCacheReadsPrice / 1_000_000) * cacheReadInputTokens
|
||||
cacheReadsCost = (modelCacheReadsPrice / 1_000_000) * cacheReadInputTokens
|
||||
}
|
||||
const baseInputCost =
|
||||
((modelInfo.inputPrice || 0) / 1_000_000) * inputTokens
|
||||
const baseInputCost = ((modelInfo.inputPrice || 0) / 1_000_000) * inputTokens
|
||||
const outputCost = ((modelInfo.outputPrice || 0) / 1_000_000) * outputTokens
|
||||
const totalCost =
|
||||
cacheWritesCost + cacheReadsCost + baseInputCost + outputCost
|
||||
const totalCost = cacheWritesCost + cacheReadsCost + baseInputCost + outputCost
|
||||
return totalCost
|
||||
}
|
||||
+3
-19
@@ -6,10 +6,7 @@ import "should"
|
||||
import { createDirectoriesForFile, fileExistsAtPath } from "./fs"
|
||||
|
||||
describe("Filesystem Utilities", () => {
|
||||
const tmpDir = path.join(
|
||||
os.tmpdir(),
|
||||
"cline-test-" + Math.random().toString(36).slice(2),
|
||||
)
|
||||
const tmpDir = path.join(os.tmpdir(), "cline-test-" + Math.random().toString(36).slice(2))
|
||||
|
||||
// Clean up after tests
|
||||
after(async () => {
|
||||
@@ -39,13 +36,7 @@ describe("Filesystem Utilities", () => {
|
||||
|
||||
describe("createDirectoriesForFile", () => {
|
||||
it("should create all necessary directories", async () => {
|
||||
const deepPath = path.join(
|
||||
tmpDir,
|
||||
"deep",
|
||||
"nested",
|
||||
"dir",
|
||||
"file.txt",
|
||||
)
|
||||
const deepPath = path.join(tmpDir, "deep", "nested", "dir", "file.txt")
|
||||
const createdDirs = await createDirectoriesForFile(deepPath)
|
||||
|
||||
// Verify directories were created
|
||||
@@ -68,14 +59,7 @@ describe("Filesystem Utilities", () => {
|
||||
})
|
||||
|
||||
it("should normalize paths", async () => {
|
||||
const unnormalizedPath = path.join(
|
||||
tmpDir,
|
||||
"a",
|
||||
"..",
|
||||
"b",
|
||||
".",
|
||||
"file.txt",
|
||||
)
|
||||
const unnormalizedPath = path.join(tmpDir, "a", "..", "b", ".", "file.txt")
|
||||
const createdDirs = await createDirectoriesForFile(unnormalizedPath)
|
||||
|
||||
// Should create only the necessary directory
|
||||
|
||||
+1
-3
@@ -8,9 +8,7 @@ import * as path from "path"
|
||||
* @param filePath - The full path to a file.
|
||||
* @returns A promise that resolves to an array of newly created directories.
|
||||
*/
|
||||
export async function createDirectoriesForFile(
|
||||
filePath: string,
|
||||
): Promise<string[]> {
|
||||
export async function createDirectoriesForFile(filePath: string): Promise<string[]> {
|
||||
const newDirectories: string[] = []
|
||||
const normalizedFilePath = path.normalize(filePath) // Normalize path for cross-platform compatibility
|
||||
const directoryPath = path.dirname(normalizedFilePath)
|
||||
|
||||
@@ -30,9 +30,7 @@ describe("Path Utilities", () => {
|
||||
it("should handle desktop path", () => {
|
||||
const desktop = path.join(os.homedir(), "Desktop")
|
||||
const testPath = path.join(desktop, "test.txt")
|
||||
getReadablePath(desktop, "test.txt").should.equal(
|
||||
testPath.replace(/\\/g, "/"),
|
||||
)
|
||||
getReadablePath(desktop, "test.txt").should.equal(testPath.replace(/\\/g, "/"))
|
||||
})
|
||||
|
||||
it("should show relative paths within cwd", () => {
|
||||
|
||||
+1
-4
@@ -72,10 +72,7 @@ function normalizePath(p: string): string {
|
||||
let normalized = path.normalize(p)
|
||||
// however it doesn't remove trailing slashes
|
||||
// remove trailing slash, except for root paths
|
||||
if (
|
||||
normalized.length > 1 &&
|
||||
(normalized.endsWith("/") || normalized.endsWith("\\"))
|
||||
) {
|
||||
if (normalized.length > 1 && (normalized.endsWith("/") || normalized.endsWith("\\"))) {
|
||||
normalized = normalized.slice(0, -1)
|
||||
}
|
||||
return normalized
|
||||
|
||||
Reference in new issue
Block a user