Extends node's assert module with methods for testing filepaths.
Install
Install with npm
$ npm i assert-path --save
Usage
var assert = ;assert;
API
- assert.dirname
- assert.basename
- assert.filename
- assert.extname
- assert.path
- assert.absolute
- assert.isAbsolute
- assert.isRelative
- assert.segments
- assert.lastSegment
assert.dirname
Returns true if path.dirname
of filepath a
equals filepath b
.
assert;
Example
assert;//=> true
assert.basename
Returns true if path.basename
of filepath a
equals filepath b
.
assert;
Example
assert;//=> true
assert.filename
Returns true if path.filename
of filepath a
equals filepath b
.
assertfilenamea b;
Example
assertfilename'a/b/ccc.js' 'ccc';//=> true
assert.extname
Returns true if path.extname
of filepath a
equals filepath b
.
assert;
Example
assert;//=> true
assert.path
Returns true if filepath a
equals filepath b
.
assert;
Example
assert;//=> true
assert.absolute
Returns true if path.resolve(a)
equals path.resolve(b)
.
assert;
Example
assert;//=> true
assert.segments
Returns true if the last nth
segments of a
equals the last nth
segments of b
. For example, the last 2 segments of foo/bar/baz/qux.md
would be baz/qux.md
.
assert;
Example
// b/c.js === 'b/c.js'assert;//=> true
assert.lastSegments
Returns true if the last nth
segments of a
equals b
.
assert;
Example
assert;//=> true
assert.isAbsolute
Returns true if a filepath is absolute.
assert;
Example
assert;//=> false assert;//=> false
assert.isRelative
Returns true if path.resolve(a)
equals path.resolve(b)
.
assert;
Example
assert;//=> trueassert;//=> false
Related projects
- is-absolute: Return true if a file path is absolute. | homepage
- is-relative: Returns
true
if the path appears to be relative. | homepage - normalize-path: Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a… more | homepage
- relative: Get the relative filepath from path A to path B. Calculates from file-to-directory, file-to-file, directory-to-file,… more | homepage
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Jon Schlinkert
License
Copyright © 2015 Jon Schlinkert Released under the MIT license.
This file was generated by verb-cli on November 08, 2015.