Skip to content

Commit

Permalink
fix: parser build
Browse files Browse the repository at this point in the history
  • Loading branch information
osipov-mit committed Nov 26, 2024
1 parent 50e3e9b commit 717ed56
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions js/parser/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { writeFileSync, rmSync, readFileSync } from 'fs';
import { writeFileSync, rmSync } from 'fs';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import config from '../config.json' assert { type: 'json' };
import { readFile } from 'fs/promises';

async function getStreamFromRelease(version, cs) {
const link = `https://github.com/gear-tech/sails/releases/download/rs%2Fv${version}/sails_idl_parser.wasm`;
Expand All @@ -15,17 +16,19 @@ async function getStreamFromRelease(version, cs) {
}

async function getStreamFromFile(cs) {
const file = readFileSync('./parser.wasm');
const file = await readFile('./parser.wasm');
return new Response(file).body.pipeThrough(cs);
}

async function getBase64Parser(version) {
const cs = new CompressionStream('gzip');

const compressedReadableStream =
process.env.BUILD_MODE.toLowerCase() === 'release' ? getStreamFromRelease(version, cs) : getStreamFromFile(cs);
const stream =
process.env.BUILD_MODE?.toLowerCase() === 'release'
? await getStreamFromRelease(version, cs)
: await getStreamFromFile(cs);

const reader = compressedReadableStream.getReader();
const reader = stream.getReader();

let resultArr = [];

Expand Down

0 comments on commit 717ed56

Please sign in to comment.