![38% of CISOs Fear They’re Not Moving Fast Enough on AI](https://cdn.sanity.io/images/cgdhsj6q/production/faa0bc28df98f791e11263f8239b34207f84b86f-1024x1024.webp?w=400&fit=max&auto=format)
Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@antora/expand-path-helper
Advanced tools
Provides a helper function to expand a path to a normalized absolute path. This function also expands dot, tilde, and tilde plus when used as the first path segment.
A Node.js module that provides a helper function to expand a path to a normalized absolute path.
This function also expands the following shorthand expressions when used as the first path segment: dot (.
), tilde (~
), or tilde plus (~+
).
The expanded path is system dependent.
Developed for use in Antora.
$ npm i @antora/expand-path-helper
function expandPath (path[, context])
Expands the specified path to a normalized absolute path. The main purpose of this function is path expansion and normalization.
path
<string> - The path to expand.
This parameter is required.
If the path is already absolute, the path is normalized and returned.context
<Object> - Named parameters that control how the path is resolved.
All named parameters are optional.
This parameter can also be specified as a String, in which case it’s used as the base context argument.
Default: {}
.
base
<string> - The base directory from which to resolve a relative path instead of the working directory.
Default: ~+
cwd
<string> - The absolute directory to use as the working directory instead of the current working directory.
If not specified, the current working directory is used.
Default: undefined
dot
<string> - The value to use to replace a leading dot (.
) segment.
If the value is .
, the value of the base
context argument is used instead.
Default: .
If the first segment of the path argument, the base context argument, or the dot context argument is ~
or ~+
, that value is expanded to the user’s home directory or current working directory, respectively.
If the first segment of the path argument is .
, that value is replaced with the dot context argument after the dot context argument is expanded.
The output of expandPath
depends on the system on which it is run (specifically on the path.sep
value).
const expandPath = require('@antora/expand-path-helper')
expandPath('/absolute/path')
//=> /absolute/path
expandPath('/absolute/./path/..')
//=> /absolute
expandPath('foo/bar')
//=> $PWD/foo/bar
expandPath('./foo/bar')
//=> $PWD/foo/bar
expandPath('~/foo/bar')
//=> $HOME/foo/bar
expandPath('~+/foo/bar')
//=> $PWD/foo/bar
expandPath('~+/foo/bar', { cwd: '/working/dir' })
//=> /working/dir/foo/bar
expandPath('foo/bar', '/base/dir')
//=> /base/dir/foo/bar
expandPath('foo/bar', { base: '/base/dir' })
//=> /base/dir/foo/bar
expandPath('./foo/bar', { base: '/base/dir' })
//=> /base/dir/foo/bar
expandPath('./foo/bar', { dot: '/dot/dir' })
//=> /dot/dir/foo/bar
const expandPath = require('@antora/expand-path-helper')
expandPath('C:\\absolute\\path')
//=> C:\absolute\path
expandPath('C:/absolute/path')
//=> C:\absolute\path
expandPath('C:\\absolute\\.\\path\\..')
//=> C:\absolute
expandPath('foo\\bar')
//=> C:\current\directory\foo\bar
expandPath('.\\foo\\bar')
//=> C:\current\directory\foo\bar
expandPath('~\\foo\\bar')
//=> C:\Users\user\foo\bar
expandPath('~+\\foo\\bar')
//=> C:\current\directory\foo\bar
expandPath('~+\\foo\\bar', { cwd: 'C:\\working\\dir' })
//=> C:\working\dir\foo\bar
expandPath('foo\\bar', 'C:\\base\\dir')
//=> C:\base\dir\foo\bar
expandPath('foo\\bar', { base: 'C:\\base\\dir' })
//=> C:\base\dir\foo\bar
expandPath('.\\foo\\bar', { base: 'C:\\base\\dir' })
//=> C:\base\dir\foo\bar
expandPath('.\\foo\\bar', { dot: 'C:\\dot\\dir' })
//=> C:\dot\dir\foo\bar
On Windows, the input path may use forward slashes, but the expanded path will always have backslashes.
Copyright (C) 2018-present by OpenDevise Inc. and the individual contributors to Antora.
Use of this software is granted under the terms of the Mozilla Public License Version 2.0 (MPL-2.0).
FAQs
Provides a helper function to expand a path to a normalized absolute path. This function also expands dot, tilde, and tilde plus when used as the first path segment.
The npm package @antora/expand-path-helper receives a total of 0 weekly downloads. As such, @antora/expand-path-helper popularity was classified as not popular.
We found that @antora/expand-path-helper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.