mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Support tilde paths ("~" prefix) in readConfig/Sync APIs (for "file" parameter and "extends" keys).
This commit is contained in:
parent
5505deb1c9
commit
ffc4d56918
6 changed files with 132 additions and 31 deletions
|
|
@ -1021,3 +1021,16 @@ function deepFreeze(obj) {
|
|||
return obj;
|
||||
}
|
||||
module.exports.deepFreeze = deepFreeze;
|
||||
|
||||
/**
|
||||
* Expands a path with a tilde to an absolute path.
|
||||
*
|
||||
* @param {string} file Path that may begin with a tilde.
|
||||
* @param {Object} os Node.js "os" module.
|
||||
* @returns {string} Absolute path (or original path).
|
||||
*/
|
||||
function expandTildePath(file, os) {
|
||||
const homedir = os && os.homedir();
|
||||
return homedir ? file.replace(/^~($|\/|\\)/, `${homedir}$1`) : file;
|
||||
}
|
||||
module.exports.expandTildePath = expandTildePath;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue