UNPKG

@stryke/path

Version:

A package containing various utilities that expand the functionality of NodeJs's built-in `path` module

1 lines 1.6 kB
{"version":3,"file":"resolve-parent-path.mjs","names":[],"sources":["../src/resolve-parent-path.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { joinPaths } from \"./join-paths\";\n\n/**\n * Resolve the parent path of the provided path.\n *\n * @param path - The path to resolve.\n * @param count - The number of parent directories to traverse.\n * @returns The parent path of the provided path.\n */\nexport const resolveParentPath = (path: string, count: number = 1): string => {\n let parentPath = path.replaceAll(/\\/+$/g, \"\");\n for (let i = 0; i < count; i++) {\n parentPath = joinPaths(parentPath, \"..\");\n }\n return parentPath;\n};\n"],"mappings":";;;;;;;;;;AA2BA,MAAa,qBAAqB,MAAc,QAAgB,MAAc;CAC5E,IAAI,aAAa,KAAK,WAAW,SAAS,GAAG;AAC7C,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,IACzB,cAAa,UAAU,YAAY,KAAK;AAE1C,QAAO"}