mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-02 13:23:51 +02:00
Fix FilePathSource/FilePathTarget not working in server-side environments using CJS (closes #360)
This commit is contained in:
+7
-1
@@ -692,12 +692,18 @@ export class FilePathTarget extends Target {
|
||||
throw new TypeError('options must be an object.');
|
||||
}
|
||||
|
||||
if (!node.getFs) {
|
||||
throw new Error(
|
||||
'FilePathTarget is only available in server-side environments (Node.js, Bun, Deno).',
|
||||
);
|
||||
}
|
||||
|
||||
super();
|
||||
|
||||
// Let's back this target with a StreamTarget, makes the implementation very simple
|
||||
const writable = new WritableStream<StreamTargetChunk>({
|
||||
start: async () => {
|
||||
this._fileHandle = await node.fs.open(filePath, 'w');
|
||||
this._fileHandle = await (await node.getFs()).open(filePath, 'w');
|
||||
},
|
||||
write: async (chunk) => {
|
||||
assert(this._fileHandle);
|
||||
|
||||
Reference in New Issue
Block a user