Skip to content

Commit

Permalink
fix: ensure resources ignition directory exists (#2684)
Browse files Browse the repository at this point in the history
  • Loading branch information
spypsy authored and Maddiaa0 committed Oct 5, 2023
1 parent 2261239 commit 32278cf
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions yarn-project/circuits.js/src/crs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fileURLToPath } from '@aztec/foundation/url';

import isNode from 'detect-node';
import { existsSync } from 'fs';
import { open } from 'fs/promises';
import { mkdir, open } from 'fs/promises';
import { dirname, join } from 'path';

/**
Expand Down Expand Up @@ -180,8 +180,12 @@ export class Crs {
await this.crs.init();
if (isNode) {
const localPath = dirname(fileURLToPath(import.meta.url)) + this.localPath;
// save downloaded CRS on file
if (this.saveOnFile && !existsSync(localPath)) {
const devPath = join(fileURLToPath(import.meta.url), this.devPath);
// save downloaded CRS on file if we don't have a local or dev version
if (this.saveOnFile && !existsSync(localPath) && !existsSync(devPath)) {
const dir = localPath.substring(0, localPath.lastIndexOf('/'));
await mkdir(dir, { recursive: true });

const fileHandle = await open(localPath, 'w');
const g1Data = Buffer.from(this.crs.getG1Data());
try {
Expand Down

0 comments on commit 32278cf

Please sign in to comment.