mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Merge pull request #297 from AtkinsSJ/test-minimum-version
Make tests work in Node 16.x
This commit is contained in:
commit
4931ad3960
2
.github/workflows/build-and-test.yml
vendored
2
.github/workflows/build-and-test.yml
vendored
@ -16,7 +16,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [20.x, 21.x]
|
||||
node-version: [16.x, 18.x, 20.x, 21.x]
|
||||
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
||||
|
||||
steps:
|
||||
|
@ -19,8 +19,9 @@
|
||||
import { Context } from "contextlink";
|
||||
import { SyncLinesReader } from '../../src/ansi-shell/ioutil/SyncLinesReader.js';
|
||||
import { CommandStdinDecorator } from '../../src/ansi-shell/pipeline/iowrappers.js';
|
||||
import { ReadableStream, WritableStream } from 'stream/web'
|
||||
|
||||
export class WritableStringStream extends WritableStream {
|
||||
class WritableStringStream extends WritableStream {
|
||||
constructor() {
|
||||
super({
|
||||
write: (chunk) => {
|
||||
@ -42,8 +43,23 @@ export class WritableStringStream extends WritableStream {
|
||||
|
||||
// TODO: Flesh this out as needed.
|
||||
export const MakeTestContext = (command, { positionals = [], values = {}, stdinInputs = [], env = {} }) => {
|
||||
// This is a replacement to ReadableStream.from() in earlier Node versions
|
||||
// Sourece: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream#convert_an_iterator_or_async_iterator_to_a_stream
|
||||
function iteratorToStream(iterator) {
|
||||
return new ReadableStream({
|
||||
async pull(controller) {
|
||||
const { value, done } = await iterator.next();
|
||||
|
||||
let in_ = ReadableStream.from(stdinInputs).getReader();
|
||||
if (done) {
|
||||
controller.close();
|
||||
} else {
|
||||
controller.enqueue(value);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
let in_ = iteratorToStream(stdinInputs.values()).getReader();
|
||||
if (command.input?.syncLines) {
|
||||
in_ = new SyncLinesReader({ delegate: in_ });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user