assert-file
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

assert-file

assert file utilities

NPM version build status Test coverage David deps Known Vulnerabilities NPM download

Installation

npm i --save assert-file

Usage

const assertFile = require('assert-file');
 
// `ok()` is alias of `assertFile()`, `fail()` is the opposite of `assertFile()`
const { ok, fail } = assertFile;
 
// check whether file exists
assertFile(`${fixtures}/package.json`);
 
// check string includes
assertFile(`${fixtures}/README.md`, 'hello');
 
// check with regex
assertFile(`${fixtures}/README.md`, /hello/);
 
// check json includes
assertFile(`${fixtures}/package.json`, { name: 'rule_file' });
 
// support multiple rule
assertFile(`${fixtures}/README.md`, [ 'hello', /world/ ]);
 
// opposite assertion
assertFile.fail(`${fixtures}/package.json`);
assertFile.fail(`${fixtures}/package.json`, { name: 'example' });
assertFile.fail(`${fixtures}/README`, /x = y/);
assertFile.fail(`${fixtures}/README`, [ 'abc', /\d+/ ]);

Readme

Keywords

none

Package Sidebar

Install

npm i assert-file

Weekly Downloads

60

Version

1.0.0

License

MIT

Unpacked Size

8.05 kB

Total Files

5

Last publish

Collaborators

  • atian25