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 d5a68e1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
8 changes: 5 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,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)(contract, workingDirectory);
const formattedDiffs = diffs.map((diff) => {
const formattedDiff = (0, format_1.formatDiff)(cmpDef, diff);
const title = format_1.diffTitles[formattedDiff.type];
Expand Down Expand Up @@ -524,6 +524,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.parseSource = exports.parseLayout = exports.createLayout = void 0;
const child_process_1 = __nccwpck_require__(2081);
const fs_1 = __importDefault(__nccwpck_require__(7147));
const path_1 = __nccwpck_require__(1017);
const parser = __importStar(__nccwpck_require__(4834));
const exactify = (variable) => ({
...variable,
Expand Down Expand Up @@ -558,8 +559,9 @@ const parseLayout = (content) => {
}
};
exports.parseLayout = parseLayout;
const parseSource = (contract) => {
const [path, contractName] = contract.split(":");
const parseSource = (contract, cwd = "") => {
const [relPath, contractName] = contract.split(":");
const path = (0, path_1.join)(cwd, relPath);
const { children, tokens = [] } = parser.parse(fs_1.default.readFileSync(path, { encoding: "utf-8" }), {
tolerant: true,
tokens: true,
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 d5a68e1

Please sign in to comment.