summaryrefslogtreecommitdiff
path: root/cli/js/ops/fs/remove.ts
blob: 52f4cad403a7a95173832ef85aa3895a1843807a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

import { sendSync, sendAsync } from "../dispatch_json.ts";
import { pathFromURL } from "../../util.ts";

export interface RemoveOptions {
  recursive?: boolean;
}

export function removeSync(
  path: string | URL,
  options: RemoveOptions = {}
): void {
  sendSync("op_remove", {
    path: pathFromURL(path),
    recursive: !!options.recursive,
  });
}

export async function remove(
  path: string | URL,
  options: RemoveOptions = {}
): Promise<void> {
  await sendAsync("op_remove", {
    path: pathFromURL(path),
    recursive: !!options.recursive,
  });
}