Skip to content

Commit

Permalink
build: update dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Feb 1, 2023
1 parent 47da4e7 commit b69b490
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
5 changes: 3 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,8 @@ const address = core.getInput("address");
const rpcUrl = core.getInput("rpcUrl");
const failOnRemoval = core.getInput("failOnRemoval") === "true";
const workingDirectory = core.getInput("workingDirectory");
const contractEscaped = contract.replace(/\//g, "_").replace(/:/g, "-");
const contractAbs = (0, path_1.join)(workingDirectory, contract);
const contractEscaped = contractAbs.replace(/\//g, "_").replace(/:/g, "-");
const getReportPath = (branch, baseName) => `${branch.replace(/[/\\]/g, "-")}.${baseName}.json`;
const baseReport = getReportPath(baseBranch, contractEscaped);
const outReport = getReportPath(headBranch, contractEscaped);
Expand Down Expand Up @@ -457,7 +458,7 @@ async function run() {
});
if (diffs.length > 0) {
core.info(`Parse source code`);
const cmpDef = (0, input_1.parseSource)(contract);
const cmpDef = (0, input_1.parseSource)(contractAbs);
const formattedDiffs = diffs.map((diff) => {
const formattedDiff = (0, format_1.formatDiff)(cmpDef, diff);
const title = format_1.diffTitles[formattedDiff.type];
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Zip from "adm-zip";
import * as fs from "fs";
import { dirname, resolve } from "path";
import { dirname, join, resolve } from "path";

import * as artifact from "@actions/artifact";
import * as core from "@actions/core";
Expand All @@ -21,7 +21,8 @@ const rpcUrl = core.getInput("rpcUrl");
const failOnRemoval = core.getInput("failOnRemoval") === "true";
const workingDirectory = core.getInput("workingDirectory");

const contractEscaped = contract.replace(/\//g, "_").replace(/:/g, "-");
const contractAbs = join(workingDirectory, contract);
const contractEscaped = contractAbs.replace(/\//g, "_").replace(/:/g, "-");
const getReportPath = (branch: string, baseName: string) =>
`${branch.replace(/[/\\]/g, "-")}.${baseName}.json`;

Expand Down Expand Up @@ -140,7 +141,7 @@ async function run() {

if (diffs.length > 0) {
core.info(`Parse source code`);
const cmpDef = parseSource(contract, workingDirectory);
const cmpDef = parseSource(contractAbs);

const formattedDiffs = diffs.map((diff) => {
const formattedDiff = formatDiff(cmpDef, diff);
Expand Down
6 changes: 2 additions & 4 deletions src/input.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { execSync } from "child_process";
import fs from "fs";
import { join } from "path";

import * as parser from "@solidity-parser/parser";
import { ContractDefinition } from "@solidity-parser/parser/src/ast-types";
Expand Down Expand Up @@ -50,9 +49,8 @@ export const parseLayout = (content: string): StorageLayoutReportExact => {
}
};

export const parseSource = (contract: string, cwd = ""): ParsedSource => {
const [relPath, contractName] = contract.split(":");
const path = join(cwd, relPath);
export const parseSource = (contract: string): ParsedSource => {
const [path, contractName] = contract.split(":");

const { children, tokens = [] } = parser.parse(fs.readFileSync(path, { encoding: "utf-8" }), {
tolerant: true,
Expand Down
4 changes: 2 additions & 2 deletions tests/input.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ describe("Input checks", () => {
expect(Object.keys(layout.types)).toHaveLength(9);
});

it("should execute parseLayout from a custom working directory", async () => {
const source = parseSource("StorageRef.sol:Storage", "tests/mocks/basic");
it("should execute parseLayout", async () => {
const source = parseSource("tests/mocks/basic/StorageRef.sol:Storage");

expect(source.def.name).toBe("Storage");
expect(source.def.baseContracts).toHaveLength(0);
Expand Down

0 comments on commit b69b490

Please sign in to comment.