Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ext/node): fix stream/promises export #19820

Merged
merged 2 commits into from
Jul 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/tests/integration/node_unit_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ util::unit_test_factory!(
process_test,
querystring_test,
readline_test,
stream_test,
string_decoder_test,
timers_test,
tls_test,
Expand Down
25 changes: 25 additions & 0 deletions cli/tests/unit_node/stream_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.

import { assert } from "../../../test_util/std/testing/asserts.ts";
import { fromFileUrl, relative } from "../../../test_util/std/path/mod.ts";
import { pipeline } from "node:stream/promises";
import { createReadStream, createWriteStream } from "node:fs";

Deno.test("stream/promises pipeline", async () => {
const filePath = relative(
Deno.cwd(),
fromFileUrl(new URL("./testdata/lorem_ipsum.txt", import.meta.url)),
);
const input = createReadStream(filePath);
const output = createWriteStream("lorem_ipsum.txt.copy");

await pipeline(input, output);

const content = Deno.readTextFileSync("lorem_ipsum.txt.copy");
assert(content.startsWith("Lorem ipsum dolor sit amet"));
try {
Deno.removeSync("lorem_ipsum.txt.copy");
} catch {
// pass
}
});
4 changes: 3 additions & 1 deletion ext/node/polyfills/stream/promises.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
// Copyright Joyent and Node contributors. All rights reserved. MIT license.

import { finished, pipeline } from "ext:deno_node/_stream.mjs";
import { Stream } from "ext:deno_node/_stream.mjs";

const { finished, pipeline } = Stream.promises;

export default {
finished,
Expand Down