Skip to main content
Module

x/dax/mod.ts>$Type

Cross platform shell tools for Deno inspired by zx.
Very Popular
Go to Latest
interface $Type
import { type $Type } from "https://deno.land/x/dax@0.9.0/mod.ts";

Call Signatures

(strings: TemplateStringsArray, ...exprs: any[]): CommandBuilder

Properties

fs: fs

Re-export of deno_std's fs module.

path: path

Re-export of deno_std's path module.

which: which

Re-export of deno_which for getting the path to an executable.

whichSync: whichSync

Similar to which, but synchronously.

Methods

request(url: string | URL): RequestBuilder

Makes a request to the provided URL throwing by default if the response is not successful.

const data = await $.request("https://plugins.dprint.dev/info.json")
 .json();
cd(path: string | URL): void

Changes the directory of the current process.

escapeArg(arg: string): string

Escapes an argument for the shell when not using the template literal.

This is done by default in the template literal, so you most likely don't need this, but it may be useful when using the command builder.

For example:

const builder = new CommandBuilder()
 .command(`echo ${$.escapeArg("some text with spaces")}`);

// equivalent to this:
const builder = new CommandBuilder()
 .command(`echo 'some text with spaces'`);

// you may just want to do this though:
const builder = new CommandBuilder()
 .command(["echo", "some text with spaces"]);
exists(path: string): Promise<boolean>

Gets if the provided path exists asynchronously.

Although there is a potential for a race condition between the time this check is made and the time some code is used, it may not be a big deal to use this in some scenarios and simplify the code a lot.

existsSync(path: string): boolean

Gets if the provided path exists synchronously.

log(...data: any[]): void

Logs with potential indentation ($.logIndent) and output of commands or request responses.

Note: Everything is logged over stderr.

logLight(...data: any[]): void

Similar to $.log, but logs out the text lighter than usual. This might be useful for logging out something that's unimportant.

logStep(firstArg: string, ...data: any[]): void

Similar to $.log, but will bold red the first word if one argument or first argument if multiple arguments.

logError(firstArg: string, ...data: any[]): void

Similar to $.logStep, but will use bold red.

logWarn(firstArg: string, ...data: any[]): void

Similar to $.logStep, but will use bold yellow.

logIndent<TResult>(action: () => TResult): TResult

Causes all $.log and like functions to be logged with indentation.

await $.logIndent(async () => {
$.log("This will be indented.");
  await $.logIndent(async () => {
    $.log("This will indented even more.");
  });
});
sleep(delay: Delay): Promise<void>

Sleep for the provided delay.

await $.sleep(1000); // ms
await $.sleep("1.5s");
await $.sleep("100ms");
withRetries<TReturn>(params: RetryOptions<TReturn>): Promise<TReturn>

Does the provided action until it succeeds (does not throw) or the specified number of retries (count) is hit.