Skip to content

Commit

Permalink
docs: add $.escapeArg (#266)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored May 4, 2024
1 parent 48f4ebe commit b90efa9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ If you do not want to escape arguments in a template literal, you can opt out co
```ts
const args = "arg1 arg2 arg3";
await $.raw`echo ${args}`; // executes as: echo arg1 arg2 arg3

// or escape a specific argument while using $.raw
const args2 = "arg1 arg2";
await $.raw`echo ${$.escape(args2)} ${args2}`; // executes as: echo "arg1 arg2" arg1 arg2
```

Providing stdout of one command to another is possible as follows:
Expand Down
20 changes: 9 additions & 11 deletions src/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ async function withServer(action: (serverUrl: URL) => Promise<void>) {
return new Response(
new ReadableStream({
start(controller) {
return new Promise<void>((resolve, reject) => {
return new Promise<void>((resolve, _reject) => {
if (signal.aborted || abortController.signal.aborted) {
return;
}
const timeoutId = setTimeout(() => {
const abortListener = () => {
clearTimeout(timeoutId);
controller.close();
resolve();
}, ms);
signal.addEventListener("abort", () => {
clearTimeout(timeoutId);
reject(new Error("Client aborted."));
});
abortController.signal.addEventListener("abort", () => {
clearTimeout(timeoutId);
reject(new Error("Client aborted."));
});
signal.removeEventListener("abort", abortListener);
abortController.signal.removeEventListener("abort", abortListener);
};
const timeoutId = setTimeout(abortListener, ms);
signal.addEventListener("abort", abortListener);
abortController.signal.addEventListener("abort", abortListener);
});
},
cancel(reason) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/server.deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const startServer: StartServerHandler = (options) => {
const server = Deno.serve({
hostname: "localhost",
onListen(details) {
const url = new URL(`http://${details.hostname}:${details.port}/`);
const url = new URL(`http://localhost:${details.port}/`);
resolve({
rootUrl: url,
shutdown: () => server.shutdown(),
Expand Down

0 comments on commit b90efa9

Please sign in to comment.