1.0.7 • Published 6 years ago

fx54-node v1.0.7

Weekly downloads
1
License
MIT
Repository
github
Last release
6 years ago

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,
}
1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago