Skip to content

Commit 1bfb81c

Browse files
authored
fix: readfile arguments and typings (#64)
* fix: readfile arguments and typings * chore: add changeset
1 parent 743d41f commit 1bfb81c

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

.changeset/selfish-brooms-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@heymp/scratchpad": patch
3+
---
4+
5+
Fix: simplify readFile arguments

src/browser.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ function nodelog(value: any) {
1111
}
1212

1313
function writeFile(path: string, data: any) {
14-
return fs.writeFile(join(process.cwd(), path), data);
14+
return fs.writeFile(path, data);
1515
}
1616

1717
function appendFile(path: string, data: any) {
18-
return fs.appendFile(join(process.cwd(), path), data);
18+
return fs.appendFile(path, data);
1919
}
2020

21-
function readFile(...args: Parameters<typeof fs.readFile>) {
22-
return fs.readFile(...args);
21+
function readFile(path: string) {
22+
return fs.readFile(path, 'utf8');
2323
}
2424

2525
export async function browser(processor: Processor) {

types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
declare function log(...args: any[]): void;
22
declare function clear(): void;
33
declare function writeFile(string, any): Promise<void>;
4+
declare function readFile(string): Promise<string>;
45
declare function appendFile(string, any): Promise<void>;

0 commit comments

Comments
 (0)