assert-file

assert file utilities

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
assert-file
1.0.04 years ago4 years agoMinified + gzip package size for assert-file in KB

Readme

assert-file
assert file utilities
!NPM versionnpm-imagenpm-url !build statustravis-imagetravis-url !Test coveragecodecov-imagecodecov-url !David depsdavid-imagedavid-url !Known Vulnerabilitiessnyk-imagesnyk-url !NPM downloaddownload-imagedownload-url

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+/ ]);