Convert an absolute path to a tilde path by replacing the user's home directory with ~
93
Evaluation — 93%
↑ 1.09xAgent success when using this tile
A CLI tool needs to display file system paths in a user-friendly way by converting paths that start with the user's home directory to tilde notation, but it must leave all other paths unchanged regardless of whether they contain the home directory string elsewhere.
/Users/john/documents/file.txt), returns the path with the home directory replaced by ~ (e.g., ~/documents/file.txt) @test~ @test/var/backup/Users/john/archive), returns the path unchanged @test/usr/local/bin), returns the path unchanged @test@generates
/**
* Transforms a file system path by replacing the home directory prefix with tilde notation.
* Paths where the home directory does not appear at the start are returned unchanged.
*
* @param {string} absolutePath - The absolute file system path to transform
* @returns {string} The transformed path with tilde notation or the original path
*/
function filterPath(absolutePath) {
// Implementation here
}
module.exports = { filterPath };Provides path transformation from absolute paths to tilde notation.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-tildify