assert-file
v1.0.0
Published
assert file utilities
Downloads
840
Readme
assert-file
assert file utilities
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+/ ]);