1.0.0 • Published 5 years ago

assert-file v1.0.0

Weekly downloads
286
License
MIT
Repository
github
Last release
5 years ago

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