JSPM

@jfonx/file-utils

3.0.1
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 8098
    • Score
      100M100P100Q141481F
    • License MIT

    Package Exports

    • @jfonx/file-utils

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@jfonx/file-utils) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    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);