From 8711e0e2eb3076abecaeb511f44877b258183e09 Mon Sep 17 00:00:00 2001 From: Marko Arambasic Date: Thu, 27 Feb 2025 16:16:39 +0100 Subject: [PATCH] fix: create node cache directory with permissions (#1642) --- packages/hardhat-zksync-node/src/downloader.ts | 3 ++- packages/hardhat-zksync-node/src/utils.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/hardhat-zksync-node/src/downloader.ts b/packages/hardhat-zksync-node/src/downloader.ts index e72167365..c7fa71847 100644 --- a/packages/hardhat-zksync-node/src/downloader.ts +++ b/packages/hardhat-zksync-node/src/downloader.ts @@ -1,7 +1,7 @@ import path from 'path'; import fse from 'fs-extra'; import chalk from 'chalk'; -import { download, getAllTags, getLatestRelease, getNodeUrl, resolveTag } from './utils'; +import { download, ensureDirectory, getAllTags, getLatestRelease, getNodeUrl, resolveTag } from './utils'; import { ZkSyncNodePluginError } from './errors'; import { DEFAULT_RELEASE_CACHE_FILE_NAME, @@ -130,6 +130,7 @@ export class RPCServerDownloader { USER_AGENT, DEFAULT_TIMEOUT_MILISECONDS, ); + await ensureDirectory(this._tagsInfoFilePath, { mode: 0o755 }); await fse.writeJSON(this._tagsInfoFilePath, { tags: allTags, latest: latestTag }); } } diff --git a/packages/hardhat-zksync-node/src/utils.ts b/packages/hardhat-zksync-node/src/utils.ts index e0507c89f..bbd3c8d4f 100644 --- a/packages/hardhat-zksync-node/src/utils.ts +++ b/packages/hardhat-zksync-node/src/utils.ts @@ -263,8 +263,8 @@ function ensureTarGzExtension(filePath: string): string { return filePath.endsWith('.tar.gz') ? filePath : `${filePath}.tar.gz`; } -async function ensureDirectory(filePath: string): Promise { - await fse.ensureDir(path.dirname(filePath)); +export async function ensureDirectory(filePath: string, options?: { mode: any }): Promise { + await fse.ensureDir(path.dirname(filePath), options); } async function moveFile(sourcePath: string, destinationPath: string): Promise {