Skip to content

Commit

Permalink
Merge branch 'ts' into adding-voice-ai
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Raghuwanshi authored Nov 3, 2024
2 parents 31dc142 + a696493 commit a3c03b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 11 additions & 9 deletions JS/edgechains/arakoodev/src/sync-rpc/lib/sync-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ function createSyncRPC(filename: string) {
throw new Error(`File not found: ${absolutePath}`);
}

const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'sync-rpc-'));
const hash = crypto.createHash('md5').update(absolutePath).digest('hex');
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "sync-rpc-"));
const hash = crypto.createHash("md5").update(absolutePath).digest("hex");
const wrapperPath = path.join(tempDir, `wrapper_${hash}.js`);

const wrapperCode = `
Expand Down Expand Up @@ -50,8 +50,8 @@ function createSyncRPC(filename: string) {

try {
const output = execSync(`node ${scriptPath}`, {
encoding: 'utf8',
stdio: ['pipe', 'pipe', 'inherit']
encoding: "utf8",
stdio: ["pipe", "pipe", "inherit"],
});

fs.unlinkSync(scriptPath);
Expand All @@ -65,15 +65,17 @@ function createSyncRPC(filename: string) {
}
return JSON.stringify(result.result);
} catch (parseError: any) {
console.error('Raw output:', trimmedOutput);
throw new Error(`Failed to parse output as JSON: ${parseError.message}\nRaw output: ${trimmedOutput}`);
console.error("Raw output:", trimmedOutput);
throw new Error(
`Failed to parse output as JSON: ${parseError.message}\nRaw output: ${trimmedOutput}`
);
}
} catch (error: any) {
fs.unlinkSync(scriptPath);
if (error) {
console.error('Execution error:', error.message);
console.error("Execution error:", error.message);
if (error.stderr) {
console.error('stderr:', error.stderr);
console.error("stderr:", error.stderr);
}
throw new Error(`Execution error: ${error.message}`);
}
Expand All @@ -82,4 +84,4 @@ function createSyncRPC(filename: string) {
};
}

export = createSyncRPC as Function;
export = createSyncRPC as Function;
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"dependencies": {
"@microsoft/eslint-formatter-sarif": "^3.1.0",
"@playwright/test": "^1.46.0",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"@typescript-eslint/eslint-plugin": "^8.12.2",
"@typescript-eslint/parser": "^8.12.2",
"axios": "^1.7.3",
"eslint": "^8.57.1",
"eslint-config-google": "^0.14.0",
Expand Down

0 comments on commit a3c03b8

Please sign in to comment.