Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Audit file/directory properties and content
JavaScript
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
dist
docs
lib
test/lib/audit-fs
.gitignore
.travis.yml
CHANGELOG.md
Gruntfile.js
LICENSE
README.md
component.json
index.js
package.json

README.md

audit-fs

Audit file/directory properties and content

  • Declare expectations with chaining. Stop at first failure.
  • Expectations: exists, hasFile, hasDir, minSize, minCount, maxCount, created, modified.
  • refute API for negating any expectation.
  • Call any shelljs method or use wrappers like hasFile().
  • Available as a grunt task.

Build Status

Examples

Expect: README.md exists, no line with console.log under lib/

var audit = new auditFs.create();
audit
  .set('dir', '/path/to/dir'); // Target directory
  .hasFile('README.md')
  .refute.grep('console.log', 'lib/**/*.js');

if (audit.pass()) {
  // Expectations met
} else {
  var rule = audit.last();
  console.log(
    'failed because rule %s with args %s returned %s',
    rule.name, JSON.stringify(rule.args), JSON.stringify(rule.res)
  );
}

Expect: Symlink present/absent

Use _() to run any ShellJS method.

audit._('test', '-L', 'mySymLink');
audit.refute._('test', '-L', 'mySymLink');

Expect: Custom rule

assert() and refute() receive an OuterShelljs instance, shelljs.

audit.assert('should ...', function(shelljs) {
  var result = false;
  // ...
  return result;
});

audit.refute('should ...', function(shelljs) {
  var result = false;
  // ...
  return result;
});

Installation

NPM

npm install audit-fs

API

Documentation

License

MIT

Tests

npm test
Something went wrong with that request. Please try again.