relative-fs

Wraps function from the fs module to make their path arguments relative to a another directory

MIT 2 个版本
安装
npm install relative-fs
yarn add relative-fs
pnpm add relative-fs
bun add relative-fs
README

relative-fs

An NPM module that can wrap the fs module to make it's path arguments relative to the current directory.

Turns this:

var path = require('path');
var fs = require('fs');

var file = fs.readFileSync(path.join(__dirname, './some-file'));

Into this:

var fs = require('relative-fs').relativeTo(__dirname);
var file = fs.readFileSync('./some-file');

The plugin is very straight-forward and does exactly what you would think in just a few lines of code.

版本列表
0.0.1 2013-12-09
0.0.0 2013-12-09