fx54-node
TypeScript icon, indicating that this package has built-in type declarations

1.0.7 • Public • Published

fx54-node

MEAN Module Build Status npm version Node.js Version

Verify the existence or content of files with a hierarchical object.

Installation

yarn add fx54-node

Run tests

yarn test

Example

Assume a directory like this:

- root
  - dir1
    a.txt
  - dir2
    b.txt

Example code:

import validator from 'fx54-node';
 
try {
  await validator.validateDirectoryAsync('./root', {
    dir1: {
      'a.txt': '<contents of a.txt>', // check the contents of a.txt
      'b.txt': false, // make sure b.txt doesn't exist
    },
    dir2: {
      'b.txt': true, // make sure b.txt exists
    },
  });
 
  console.log('Validation succeeded');
} catch (err) {
  console.log(`Validation failed: ${err.message}`);
}

API

  • async validateFileAsync(path: string, value: any): validates a file with a possible value.

    • string value: tests equality of the contents of file.
    • boolean value: verifies existence of the file.
  • async validateDirectoryAsync(path: string, obj: any): validates a directory with a hierarchical object. For example:

{
  dirA: {
    subDirA: {
      file1: true,
    },
    subDirB: {
      file2: "<contents>",
    },
  },
  file3: false,
}

Readme

Keywords

Package Sidebar

Install

npm i fx54-node

Weekly Downloads

0

Version

1.0.7

License

MIT

Unpacked Size

14.8 kB

Total Files

15

Last publish

Collaborators

  • mgenware