Skip to content
Snippets Groups Projects
Select Git revision
  • 78ef5e9eebb83daa8b6a55e867b10ab41d2d8851
  • master default protected
  • no-goprocess
  • spellcheck
  • docs-release-checklist-037
  • release
  • release-v0.36.0
  • telemetry-plugin2
  • telemetry-plugin
  • reprovide-sweep
  • fix-editor-env-handling
  • ux-acc-dht-note
  • fix-flush-files-rm
  • unixfs-percent-encoding-poc
  • fix-flaky-verify-test
  • fix/systemd-path
  • release-v0.35.0
  • staging
  • split-delegated-rotuing-config
  • release-v0.34.0
  • release-v0.33.1
  • v0.36.0
  • v0.36.0-rc2
  • v0.36.0-rc1
  • v0.35.0
  • v0.35.0-rc2
  • v0.35.0-rc1
  • v0.34.1
  • v0.34.0
  • v0.34.0-rc2
  • v0.34.0-rc1
  • v0.33.2
  • v0.33.1
  • v0.33.0
  • v0.33.0-rc3
  • v0.33.0-rc2
  • v0.33.0-rc1
  • v0.32.1
  • v0.32.0
  • v0.32.0-rc2
  • v0.32.0-rc1
41 results

docker-compose.yaml

Blame
  • fs.ts 1.05 KiB
    import { parse, join } from 'upath';
    import { outputFile, readFile } from 'fs-extra';
    import { logger } from '../logger';
    
    let localDir = '';
    
    export function setFsConfig(config: any): void {
      localDir = config.localDir;
    }
    
    export function getSubDirectory(fileName: string): string {
      return parse(fileName).dir;
    }
    
    export function getSiblingFileName(
      existingFileNameWithPath: string,
      otherFileName: string
    ): string {
      const subDirectory = getSubDirectory(existingFileNameWithPath);
      return join(subDirectory, otherFileName);
    }
    
    export async function readLocalFile(fileName: string): Promise<string> {
      const localFileName = join(localDir, fileName);
      try {
        const fileContent = await readFile(localFileName, 'utf8');
        return fileContent;
      } catch (err) /* istanbul ignore next */ {
        logger.trace({ err }, 'Error reading local file');
        return null;
      }
    }
    
    export async function writeLocalFile(
      fileName: string,
      fileContent: string
    ): Promise<void> {
      const localFileName = join(localDir, fileName);
      await outputFile(localFileName, fileContent);
    }