mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 11:27:59 +00:00
Move @parity/resolc from js-revive (#296)
- Move npm package from paritytech/js-revive - Rename package to `@parity/resolc`
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
const soljson = require("solc/soljson");
|
||||
const createRevive = require("./resolc.js");
|
||||
|
||||
async function compile(standardJsonInput) {
|
||||
if (!standardJsonInput) {
|
||||
throw new Error("Input JSON for the Solidity compiler is required.");
|
||||
}
|
||||
|
||||
// Initialize the compiler
|
||||
const compiler = createRevive();
|
||||
compiler.soljson = soljson;
|
||||
|
||||
// Provide input to the compiler
|
||||
compiler.writeToStdin(JSON.stringify(standardJsonInput));
|
||||
|
||||
// Run the compiler
|
||||
compiler.callMain(["--standard-json"]);
|
||||
|
||||
// Collect output
|
||||
const stdout = compiler.readFromStdout();
|
||||
const stderr = compiler.readFromStderr();
|
||||
|
||||
// Check for errors and throw if stderr exists
|
||||
if (stderr) {
|
||||
throw new Error(`Compilation failed: ${stderr}`);
|
||||
}
|
||||
|
||||
// Return the output if no errors
|
||||
return stdout;
|
||||
}
|
||||
|
||||
module.exports = { compile };
|
||||
Reference in New Issue
Block a user