Skip to content

About

Common file system functions when working in Clay

Resources

Stars

0 stars

Watchers

14 watching

Forks

Repository files navigation

Amphora FS

CI

Utility functions for working with the file system in Clay. This module will assume that the process which is running will be triggered from a directory that contains a package.json file and /components directory.

Installation

Node 26.12.1 or later.

npm install --save amphora-fs

Methods

Good to know

  • The lists and files are read once. getComponents, getLayouts, getFiles, getFolders, isDirectory, getYaml, tryRequire, getComponentModule and getComponentPackage remember what they found for each argument, including that something was not found, so a file added later is not seen. Each one has a cache (a Map) that can be cleared.
  • getYaml(path) reads path.yaml, or path.yml if there is no .yaml or it is empty. It is null if there is no file (undefined for a missing config or local), and throws, naming the file, if the yaml is not valid.
  • In config and local files, ${NAME} is replaced by the environment variable NAME, which must be set and not empty.
  • Yaml is read with js-yaml 3 (safeLoad): numbers by YAML 1.1 rules (0777 is 511, 12:30 is 750, yes is a string), merge keys, timestamps, no js types.

Development

npm test

runs ESLint and the tests (node --test), and checks that every function still gives what amphora-fs 2.0.0 gave on a project that looks like a Clay site (test/golden.test.js).

About

Common file system functions when working in Clay

Resources

Stars

0 stars

Watchers

14 watching

Forks

Releases

Packages

Used by

Contributors

Languages