fs-sync-safe

0.1.0 • Public • Published

fs SyncSafe

A wrapper around fs.readFileSync that captures the exception and returns an empty string if file is not found, also logs the exception to a error log object or console.log if an error log object is not injected.

It also converts a buffer into a string.

Why?

This is primarily good for reading files for configuration purposes, like ssl certs, and any other dynamically placed config file by your server automation.

Install

npm install fs-syncsafe

API

function ss(name, [logfn]) return [string|empty]

Usage

var ss = require('fs-syncsafe');
 
var foo = ss('./README.md');
console.log(foo);

Contributions

Pull Request Welcome.

License

MIT

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i fs-sync-safe

    Weekly Downloads

    1

    Version

    0.1.0

    License

    MIT

    Last publish

    Collaborators

    • twilson63