Skip to content

Commit

Permalink
import conts from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Raid Ateir committed Apr 24, 2024
1 parent 7f0d1e3 commit 1aebd66
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
13 changes: 8 additions & 5 deletions core/tests/ts-integration/scripts/build.ts
@@ -1,10 +1,13 @@
import path from 'path';
import { exec } from 'child_process';
import { needsRecompilation, setCompilationTime, isFolderEmpty } from './utils';

const CONTRACTS_DIR = 'contracts';
const OUTPUT_DIR = 'artifacts-zk';
const TIMESTAMP_FILE = 'last_compilation.timestamp'; // File to store the last compilation time
import {
needsRecompilation,
setCompilationTime,
isFolderEmpty,
CONTRACTS_DIR,
OUTPUT_DIR,
TIMESTAMP_FILE
} from './utils';

async function main() {
const timestampFilePath = path.join(process.cwd(), TIMESTAMP_FILE);
Expand Down
6 changes: 2 additions & 4 deletions core/tests/ts-integration/scripts/compile-yul.ts
Expand Up @@ -5,12 +5,10 @@ import { exec as _exec, spawn as _spawn } from 'child_process';
import { getZksolcUrl, saltFromUrl } from '@matterlabs/hardhat-zksync-solc';
import { getCompilersDir } from 'hardhat/internal/util/global-dir';
import path from 'path';
import { needsRecompilation, setCompilationTime } from './utils';
import { needsRecompilation, setCompilationTime, CONTRACTS_DIR, TIMESTAMP_FILE_YUL } from './utils';

const CONTRACTS_DIR = 'contracts';
const COMPILER_VERSION = '1.3.21';
const IS_COMPILER_PRE_RELEASE = false;
const TIMESTAMP_FILE = 'last_compilation_yul.timestamp'; // File to store the last compilation time

async function compilerLocation(): Promise<string> {
const compilersCache = await getCompilersDir();
Expand Down Expand Up @@ -87,7 +85,7 @@ class CompilerPaths {
}

async function main() {
const timestampFilePath = path.join(process.cwd(), TIMESTAMP_FILE);
const timestampFilePath = path.join(process.cwd(), TIMESTAMP_FILE_YUL);
const folderToCheck = path.join(process.cwd(), CONTRACTS_DIR);

if (needsRecompilation(folderToCheck, timestampFilePath)) {
Expand Down
7 changes: 7 additions & 0 deletions core/tests/ts-integration/scripts/utils.ts
Expand Up @@ -3,6 +3,11 @@ import * as fsPr from 'fs/promises';
import path from 'path';
import { exec } from 'child_process';

const CONTRACTS_DIR = 'contracts';
const OUTPUT_DIR = 'artifacts-zk';
const TIMESTAMP_FILE = 'last_compilation.timestamp'; // File to store the last compilation time
const TIMESTAMP_FILE_YUL = 'last_compilation_yul.timestamp'; // File to store the last compilation time

// Get the latest file modification time in the watched folder
function getLatestModificationTime(folder: string): Date | null {
const files = fs.readdirSync(folder);
Expand Down Expand Up @@ -78,3 +83,5 @@ export async function isFolderEmpty(folderPath: string): Promise<boolean> {
return true; // Return true if an error, as folder doesn't exist.
}
}

export { CONTRACTS_DIR, OUTPUT_DIR, TIMESTAMP_FILE, TIMESTAMP_FILE_YUL };
13 changes: 8 additions & 5 deletions etc/contracts-test-data/scripts/build.ts
@@ -1,11 +1,14 @@
import path from 'path';
import { needsRecompilation, setCompilationTime, isFolderEmpty } from './utils';
import {
needsRecompilation,
setCompilationTime,
isFolderEmpty,
CONTRACTS_DIR,
OUTPUT_DIR,
TIMESTAMP_FILE
} from './utils';
import { exec } from 'child_process';

const CONTRACTS_DIR = 'contracts';
const OUTPUT_DIR = 'artifacts-zk';
const TIMESTAMP_FILE = 'last_compilation.timestamp'; // File to store the last compilation time

async function main() {
const timestampFilePath = path.join(process.cwd(), TIMESTAMP_FILE);
const folderToCheck = path.join(process.cwd(), CONTRACTS_DIR);
Expand Down
6 changes: 6 additions & 0 deletions etc/contracts-test-data/scripts/utils.ts
Expand Up @@ -3,6 +3,10 @@ import * as fsPr from 'fs/promises';
import path from 'path';
import { exec } from 'child_process';

const CONTRACTS_DIR = 'contracts';
const OUTPUT_DIR = 'artifacts-zk';
const TIMESTAMP_FILE = 'last_compilation.timestamp'; // File to store the last compilation time

// Get the latest file modification time in the watched folder
function getLatestModificationTime(folder: string): Date | null {
const files = fs.readdirSync(folder);
Expand Down Expand Up @@ -78,3 +82,5 @@ export async function isFolderEmpty(folderPath: string): Promise<boolean> {
return true; // Return true if an error, as folder doesn't exist.
}
}

export { CONTRACTS_DIR, OUTPUT_DIR, TIMESTAMP_FILE };

0 comments on commit 1aebd66

Please sign in to comment.