Skip to content

Commit

Permalink
Automatically applying Prettier changes
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Nov 3, 2024
1 parent c6527d5 commit a696493
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
30 changes: 16 additions & 14 deletions JS/edgechains/arakoodev/src/sync-rpc/lib/sync-rpc.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { execSync } from 'child_process';
import path from 'path';
import fs from 'fs';
import crypto from 'crypto';
import os from 'os';
import { execSync } from "child_process";
import path from "path";
import fs from "fs";
import crypto from "crypto";
import os from "os";

function createSyncRPC(filename: string) {
const absolutePath = path.resolve(filename);
Expand All @@ -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 a696493

Please sign in to comment.