@jfonx/file-utils
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

file-utils

Allows you to perform specific operations on files

Installation

npm install @jfonx/file-utils

Usage

import { findUpJsonFile, toObject, writeFile } from '@jfonx/file-utils';

/* Write a file on the disk */
writeFile({
  file: __dirname + '/filename.txt',
  content: 'I am programmer',
  force: true, // Force rewrite if the file exists
});

/* Read the contents of a JSON file and convert it to an object */
toObject(__dirname + '/tsconfig.json', true /* exit program if error */);

/* Looks for a json file recursively back and stops as soon as the file is found or the root of the hard drive is reached*/
const module = findUpJsonFile({
  filename: 'package.json' /* The desired JSON file */,
  isJson: true,
  rootDir: __dirname /* From this folder */,
});
console.log(module);

Readme

Keywords

none

Package Sidebar

Install

npm i @jfonx/file-utils

Weekly Downloads

8,915

Version

3.0.1

License

MIT

Unpacked Size

5.88 kB

Total Files

8

Last publish

Collaborators

  • justkey