Skip to content

Commit ca28311

Browse files
committed
feat: service.clean clean up service log files
1 parent 606e2ea commit ca28311

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/service.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export const MACOS_SERVICE_PATH = {
2727
/**
2828
* Cloudflared Service API.
2929
*/
30-
export const service = { install, uninstall, exists, log, err, current };
30+
export const service = { install, uninstall, exists, log, err, current, clean };
3131

3232
/**
3333
* Throw when service is already installed.
@@ -187,6 +187,22 @@ export function current(): {
187187
};
188188
}
189189

190+
/**
191+
* Clean up service log files.
192+
*/
193+
export function clean(): void {
194+
if (process.platform !== "darwin") {
195+
throw new Error(`Not Implemented on platform ${process.platform}`);
196+
}
197+
198+
if (exists()) {
199+
throw new AlreadyInstalledError();
200+
}
201+
202+
fs.rmSync(MACOS_SERVICE_PATH.OUT, { force: true });
203+
fs.rmSync(MACOS_SERVICE_PATH.ERR, { force: true });
204+
}
205+
190206
/**
191207
* Check if cloudflared service is installed.
192208
* @returns true if service is installed, false otherwise.

0 commit comments

Comments
 (0)