Skip to content

Releases: dsherret/dax

0.28.0

22 Feb 17:28
24a7548
Compare
Choose a tag to compare

What's Changed

  • feat: PathRef - support creating via import.meta and file url strings by @dsherret in #113

You can now create path references from import.meta (or import.meta.url). This allows you to more easily reference paths relative the current module instead of relying on the current working directory the script was executed from:

const currentFile = $.path(import.meta);
const parentDir = currentFile.parentOrThrow(); // or currentFile.join("../")

Full Changelog: 0.27.0...0.28.0

0.27.0

16 Feb 04:05
f69085e
Compare
Choose a tag to compare

What's Changed

  • feat: allow for masked characters when prompting for user input by @andrewbrey in #108
  • feat: PathRef - add expandGlob and readDirFilePaths by @dsherret in #109
  • feat: PathRef - make mkdir recursive by default by @dsherret in #110
  • feat: PathRef - support writing to file in non-existent dir without bothering to mkdir by @dsherret in #111
  • feat: PathRef - readDir() and readDirSync return a WalkEntry (includes path) by @dsherret in #112

Full Changelog: 0.26.0...0.27.0

0.26.0

12 Feb 04:37
1e40286
Compare
Choose a tag to compare

What's Changed

Sometimes I realize a few things after releasing, so this is a quick release. See the new Path API here: https://github.com/dsherret/dax#path-api

Full Changelog: 0.25.0...0.26.0

0.25.0

12 Feb 04:06
5ae66f8
Compare
Choose a tag to compare

What's Changed

  • feat: path API by @dsherret in #97
  • refactor: remove $.exists/existsSync(...) - Use $.path(...).existsSync() by @dsherret in #99
    • Use the Path API instead: $.path(...).existsSync() -- it's much better
  • docs: improve PathReference documentation by @dsherret in #100

This release has a new path API to help simplify working with paths.

// create a `PathReference`
let srcDir = $.path("src");
// get information about the path
srcDir.isDir(); // false
// do actions on it
srcDir.mkdir();
srcDir.isDir(); // true

srcDir.isRelative(); // true
srcDir = srcDir.resolve(); // resolve the path to be absolute
srcDir.isRelative(); // false
srcDir.isAbsolute(); // true

// join to get other paths and do actions on them
const textFile = srcDir.join("file.txt");
textFile.writeTextSync("some text");
console.log(textFile.textSync()); // "some text"

const jsonFile = srcDir.join("subDir", "file.json");
jsonFile.parentOrThrow().mkdir();
jsonFile.writeJsonSync({
  someValue: 5,
});
console.log(jsonFile.jsonSync().someValue); // 5

Full Changelog: 0.24.1...0.25.0

0.24.1

15 Jan 22:28
77c2e70
Compare
Choose a tag to compare

What's Changed

  • fix(rm): ignore NotFound errors when --force flag is set by @pkedy in #93
  • fix: copy path resolution by @sigmaSd in #87

New Contributors

  • @pkedy made their first contribution in #93

Full Changelog: 0.24.0...0.24.1

0.24.0

15 Jan 01:11
016c52b
Compare
Choose a tag to compare

What's Changed

  • feat: add touch command by @sigmaSd in #88
  • fix: handle directory specified for pipeToPath by @sigmaSd in #86
  • fix: improve error message when using the same .stdin twice when spawning a command by @dsherret in #84
  • feat: support providing a delay to RequestBuilder#timeout by @dsherret in #91
  • feat: add minutes and hours to Delay options by @dsherret in #92
  • docs: add note about how cross platform commands can be bypassed by @dsherret in #89

Full Changelog: 0.23.0...0.24.0

0.23.0

10 Jan 01:45
574a19c
Compare
Choose a tag to compare

What's Changed

  • feat: ability to add extra functions to $ #78
  • feat: add streaming api for command inputs and outputs #82
  • feat: explicit capturing of the combined stdout and stderr (BREAKING CHANGE) #80
  • fix: exit command should work in boolean list if not first item #81

Adding extra functions to $

In addition to setting different defaults for commands and requests, you can now also add your own functions to $ when you build a custom $:

import { build$, CommandBuilder, RequestBuilder } from "https://deno.land/x/dax@0.23.0/mod.ts";

const $ = build$({
  commandBuilder: new CommandBuilder()
    .cwd("./subDir")
    .env("HTTPS_PROXY", "some_value"),
  requestBuilder: new RequestBuilder()
    .header("SOME_NAME", "some value"),
  extras: {
    add(a: number, b: number) {
      return a + b;
    },
  },
});

await $`deno run my_script.ts`;
console.log(await $.request("https://plugins.dprint.dev/info.json").json());

// use your custom function
console.log($.add(1, 2));

Streaming API / CommandChild

The .spawn() method on a CommandBuilder will now return a CommandChild:

import $ from "https://deno.land/x/dax@0.23.0/mod.ts";

const child = $`echo 1 && sleep 2 && echo 2`.stdout("pipe").spawn();

This provides child.abort() to kill the child shell and two new methods for streaming the output—child.stdout() and child.stderr(). These return web streams that can be provided to the body of $.request or stdin of another command.

For example, the following will output 1, wait 2 seconds, then output 2 to the current process' stderr:

const child = $`echo 1 && sleep 2 && echo 2`.stdout("piped").spawn();
await $`deno eval 'await Deno.stdin.readable.pipeTo(Deno.stderr.writable);'`
  .stdin(child.stdout());

Explicit capturing of the combined stdout and stderr - BREAKING CHANGE

Previously, Dax would implicitly do a combined stdout and stderr capture when you piped both stdout and stderr. This would use more memory if necessary in some cases and led to some complexity with the new streaming API. You now have to explicitly opt in to get this output by toggling the captureCombined() builder method:

const result = await $`deno eval 'console.log(1); console.error(2); console.log(3);'`
  .captureCombined();

console.log(result.combined); // 1\n2\n3\n

Note: this will set stdout and stderr to "piped" if not already either "piped" or "inheritPiped".

Full Changelog: 0.22.0...0.23.0

0.22.0

07 Jan 21:45
29aad94
Compare
Choose a tag to compare

What's Changed

  • fix: handle pipeToPath(undefined, opts) correctly by @sigmaSd in #69
  • refactor: use a top level await for the wasm instance to improve the api by @dsherret in #72
  • feat: add $.commandExists, $.dedent, and $.stripAnsi by @andrewbrey in #71
  • feat: add hybrid way of providing message with options to progress and selection apis by @dsherret in #73
  • feat: $.commandExists should take into account registered commands on the $ by @dsherret in #74
  • feat: upgrade to deno_std 0.171 by @dsherret in #75

New Contributors

Full Changelog: 0.21.0...0.22.0

0.21.0

02 Jan 22:47
3a94986
Compare
Choose a tag to compare

What's Changed

  • feat(pipeToPath): return the downloaded file path by @sigmaSd in #65
  • fix: resolve the path immediately in pipeToPath by @dsherret in #67
  • feat(request): pipeToPath - support providing single WriteFileOptions argument by @dsherret in #68

Full Changelog: 0.20.0...0.21.0

0.20.0

31 Dec 00:28
4886569
Compare
Choose a tag to compare

What's Changed

  • fix: $.request was not cancelling the body on non-2xx status code in #61
  • feat: cross platform shebang support in #62

Full Changelog: 0.19.0...0.20.0