Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@technician/fs-config-source
Advanced tools
Access config on your local filesystem with Technician.
A config source for accessing config stored on the filesystem.
The FSConfigSource accesses the contents of an entire directory, allowing access to several config files stored in the same location. It useable as both an async and sync config source.
This package provides the FSConfigSource
for use with the Technician manager.
npm i @technician/fs-config-source
This package is compatible with Node 10 LTS and up.
import {Technician, DefaultInterpreters} from 'technician';
import {FSConfigSource} from '@technician/fs-config-source'
const technician = new Technician(DefaultInterpreters.asText('utf8'));
technician.addSource(new FSConfigSource());
// By default, FSConfigSource reads from process.cwd();
await technician.read('.myapprc');
await technician.read('something-else.json');
import {Technician, DefaultInterpreters} from 'technician';
import {FSConfigSource} from '@technician/fs-config-source'
const technician = new Technician(DefaultInterpreters.asJSON('utf8'));
technician.addSource(new FSConfigSource());
const config = await technician.read('config.json');
// The default asJSON interpreter can read and return JSON files as a js object.
// Non-JSON will be ignored with `asJSON`.
// You can use `asTextOrJSON` to optionally parse only valid JSON.
db.connect(config.dbUsername, config.dbPassword);
// ...
// Provide an absolute path to a directory.
technician.addSource(new FSConfigSource('/home/me/my-config-dir'));
// The relativeRootPath option will look inside process.cwd() for your custom path.
technician.addSource(new FSConfigSource('app-config-dir', {relativeRootPath: true}));
// ...
// ...
// Allows recursive access to subdirectories.
technician.addSource(new FSConfigSource(), {recurse: true});
// Read a file at the top level...
await technician.read('top-level-file.txt');
// ... or within nested subdirectories
await technician.read('subdirectory/another-file.txt');
// Note that subdirectories are not expanded into objects with readAll(),
// but instead keep the same flat key structure used by read().
// Ex: {"top-level-file.txt": "contents", "subdirectory/another-file.txt": "contents"}
By default, the FSConfigSource suppresses all filesystem errors (except in the case that the rootPath
passed to the constructor is invalid), instead treating any unreadable files as simply nonexistent.
To throw these errors instead, use the {throwErrors: true}
option. Note that this will cause readAll()
to throw an error if the target directory contains any inaccessible files, even if others are valid.
Contributions and pull requests are always welcome. Please be sure your code passes all existing tests and linting.
Pull requests with full code coverage are strongly encouraged.
FAQs
Access config on your local filesystem with Technician.
We found that @technician/fs-config-source demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.