fs-cd

1.0.1 • Public • Published

fs-cd

Node file system addition where it automatically uses the current directory.

Installation

npm install fs-cd

The motivation

Normally let's say you have a file system like this:

  • folder1
    • folder2
      • file1.js
    • folder3
      • file2.js
// file1.js
require("../folder3/file2.js");

// file2.js
const fs = require("fs-cd")(__dirname);
console.log(fs.readdirSync("."));

With the normal fs you would expect it to log out ["file1.js"] since it's the actual source.

With the fs-cd, it uses the current directory which results with it logging out ["file2.js"]

Usage

const fs = require("fs-cd")(__dirname);

console.log(fs.readFileSync("./hello.txt", "utf8"));

Readme

Keywords

none

Package Sidebar

Install

npm i fs-cd

Weekly Downloads

2

Version

1.0.1

License

ISC

Unpacked Size

2.69 kB

Total Files

4

Last publish

Collaborators

  • oguzhanumutlu