Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@latticexyz/gas-report

Package Overview
Dependencies
Maintainers
4
Versions
1208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@latticexyz/gas-report - npm Package Compare versions

Comparing version 2.0.0-main-d62e76d2 to 2.0.0-main-d844cd44

dist/chunk-OPZOQG5Z.js

2

dist/index.js

@@ -1,2 +0,2 @@

import{a}from"./chunk-P7EYZ5QJ.js";export{a as default};
import{a}from"./chunk-OPZOQG5Z.js";export{a as default};
//# sourceMappingURL=index.js.map
{
"name": "@latticexyz/gas-report",
"version": "2.0.0-main-d62e76d2",
"version": "2.0.0-main-d844cd44",
"description": "Gas reporter for specific lines within forge tests",

@@ -23,3 +23,3 @@ "repository": {

"bin": {
"mud-gas-report": "./dist/mud-gas-report.js"
"gas-report": "./dist/gas-report.js"
},

@@ -30,2 +30,3 @@ "dependencies": {

"execa": "^7.0.0",
"stream-to-array": "^2.3.0",
"strip-ansi": "^7.1.0",

@@ -37,2 +38,3 @@ "table": "^6.8.1",

"@types/node": "^18.15.11",
"@types/stream-to-array": "^2.3.1",
"@types/yargs": "^17.0.10",

@@ -49,4 +51,5 @@ "ds-test": "https://github.com/dapphub/ds-test.git#e282159d5170298eb2455a6c05280ab5a73a4ef0",

"dev": "tsup --watch",
"test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests && forge test"
"test": "vitest typecheck --run --passWithNoTests && vitest --run --passWithNoTests && forge test",
"test:ci": "pnpm run test"
}
}

@@ -23,5 +23,5 @@ # Gas Report

```console
pnpm mud-gas-report --save gas-report.json
pnpm gas-report --save gas-report.json
```
Run `pnpm mud-gas-report --help` for more details.
Run `pnpm gas-report --help` for more details.

@@ -7,2 +7,3 @@ import type { CommandModule } from "yargs";

import stripAnsi from "strip-ansi";
import toArray from "stream-to-array";

@@ -35,2 +36,3 @@ /**

compare?: string;
stdin?: boolean;
};

@@ -57,9 +59,13 @@

compare: { type: "string", desc: "Compare to an existing gas report" },
stdin: {
type: "boolean",
desc: "Parse the gas report logs from stdin instead of running an internal test command",
},
});
},
async handler({ save, compare }) {
async handler(options) {
let gasReport: GasReport;
try {
gasReport = await runGasReport();
gasReport = await runGasReport(options);
} catch (error) {

@@ -72,2 +78,3 @@ console.error(error);

// If this gas report should be compared to an existing one, load the existing one
let { compare } = options;
if (compare) {

@@ -91,3 +98,3 @@ try {

// Save gas report to file if requested
if (save) saveGasReport(gasReport, save);
if (options.save) saveGasReport(gasReport, options.save);

@@ -100,3 +107,3 @@ process.exit(0);

async function runGasReport(): Promise<GasReport> {
async function runGasReport(options: Options): Promise<GasReport> {
console.log("Running gas report");

@@ -106,10 +113,18 @@ const gasReport: GasReport = [];

// Extract the logs from the child process
let stdout: string;
let logs: string;
try {
// Run the generated file using forge
const child = execa("forge", ["test", "-vvv"], {
stdio: ["inherit", "pipe", "inherit"],
env: { GAS_REPORTER_ENABLED: "true" },
});
stdout = (await child).stdout;
if (options.stdin) {
// Read the logs from stdin and pipe them to stdout for visibility
console.log("Waiting for stdin...");
process.stdin.pipe(process.stdout);
logs = (await toArray(process.stdin)).map((chunk) => chunk.toString()).join("\n");
console.log("Done reading stdin");
} else {
// Run the default test command to capture the logs
const child = execa("forge", ["test", "-vvv"], {
stdio: ["inherit", "pipe", "inherit"],
env: { GAS_REPORTER_ENABLED: "true" },
});
logs = (await child).stdout;
}
} catch (error: any) {

@@ -122,3 +137,3 @@ console.log(error.stdout ?? error);

// Extract the gas reports from the logs
const lines = stdout.split("\n").map(stripAnsi);
const lines = logs.split("\n").map(stripAnsi);
const gasReportPattern = /^\s*GAS REPORT: (\d+) (.*)$/;

@@ -125,0 +140,0 @@ const testFunctionPattern = /^\[(?:PASS|FAIL).*\] (\w+)\(\)/;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc