-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update arc write full path on output
- Loading branch information
1 parent
39d0f06
commit 0ca2966
Showing
3 changed files
with
38 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import fs from 'node:fs/promises' | ||
import path from 'node:path' | ||
|
||
export async function writeFile(filepath: string, content: string) { | ||
const dirPath = path.dirname(filepath) | ||
if (!(await fs.exists(dirPath))) { | ||
await fs.mkdir(dirPath, { recursive: true }) | ||
} | ||
|
||
const bytes = await Bun.write(filepath, content) | ||
|
||
return { | ||
filepath: filepath, | ||
size: bytes, | ||
} | ||
} | ||
|
||
export async function readFile(filepath: string) { | ||
const file = Bun.file(filepath) | ||
const content = await file.text() | ||
return { | ||
file: content, | ||
filepath: filepath, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters