package
path-extra contains methods that aren't included in the vanilla Node.js path package.
npm install path-extraGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
This module simply modifies the Node.js 'path' object with extra methods. It is a drop in replacement for the path module.
$ npm install path-extravar path = require('path-extra');You can still use all of the vanilla Node.js path methods.
replaceExt(filePath, extension)Replaces the extension from path with extension and returns the updated path string.
From the module replace-ext.
Example:
path.replaceExt('dir/file.md', '.html')
// => 'dir/file.html'normalizeTrim(filePath)A path.normalize() that trims trailing slashes. Useful for comparing file paths.
Example:
path.normalize('/foo/bar//baz/asdf/quux/../')
// => /foo/bar/baz/asdf/
path.normalizeTrim('/foo/bar//baz/asdf/quux/../')
// => /foo/bar/baz/asdfbase(filePath, [includeExt])A smart wrapper for path.basename().
includeExt is false, returns the basename without an extension (path.basename(filePath, path.extname(filePath))).includeExt is true, works like path.basename(filePath).includeExt is false by default.Example:
path.base('path/to/file.md')
// => file
path.base('path/to/file.md', false)
// => file
path.base('path/to/file.md', true)
// => file.mdremoveExt(filepath)Remove a path's extension.
Example:
path.removeExt('some/dir/file.ext')
// => some/dir/filefileNameWithPostfix(filePath, postfix)Append string to the end of the filename.
Example:
path.fileNameWithPostfix('path/to/file-name.ext', '-old')
// => path/to/file-name-old.extfileNameWithPrefix(filePath, prefix)Append string to the beginning of the filename.
Example:
path.fileNameWithPrefix('path/to/file-name.ext', 'new-')
// => path/to/new-file-name.exthomedir(), tempdir(), and datadir() have been removed in version 4.0.0. Please use the ospath module instead.
(The MIT License)
Copyright (c) 2011-2015 JP Richardson
ryanzim
opensrc@ryanzim.com
Estimated unpacked size across 3 packages.
20.0 kB
Includes dependencies.
2 direct · 2 outdated
^1.0.0
2.0.0
^1.0.5
5.0.0