Releases: dsherret/dax
0.28.0
What's Changed
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
What's Changed
- feat: allow for masked characters when prompting for user input by @andrewbrey in #108
- feat:
PathRef
- addexpandGlob
andreadDirFilePaths
by @dsherret in #109 - feat:
PathRef
- makemkdir
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()
andreadDirSync
return aWalkEntry
(includes path) by @dsherret in #112
Full Changelog: 0.26.0...0.27.0
0.26.0
What's Changed
- refactor:
PathReference
->PathRef
by @dsherret in #102 - feat(pathref): add custom instanceof which will work between versions by @dsherret in #103
- feat: upgrade to deno_std 0.177 by @dsherret in #104
- docs: fix the
PathRef
docs more by @dsherret in #101
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
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
- Use the Path API instead:
- 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
0.24.0
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
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
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
- @andrewbrey made their first contribution in #71
Full Changelog: 0.21.0...0.22.0