{"version":3,"sources":["jsdelivr-header.js","/npm/nodejs-project-folder@1.0.1/api.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,IAAI,KAAO,QAAQ,QAInB,MAAM,YACJ,WAAA,GACE,KAAK,QAAU,KAAK,QAAQ,KAC5B,KAAK,MAAQ,EACf,CAMA,oBAAA,GACE,IAAI,EAAa,UACb,EAAY,KAAK,QAAQ,GAG7B,GAAkB,gBAFD,EAAU,MAAM,KAAK,KAAK,MAET,CAChC,IAAI,EAAiB,KAAK,QAAQ,GAClC,KAAK,QAAU,CACjB,CAEA,OAAO,IACT,CAMA,MAAA,CAAO,GACL,GAAI,EAAI,SAAS,KAAK,KAAM,CACd,EAAI,MAAM,KAAK,KAErB,SAAQ,IACR,GACF,KAAK,MAAM,KAAK,EAAE,GAExB,MAEE,KAAK,MAAM,KAAK,GAElB,OAAO,IACT,CAKA,YAAA,GACE,OAAO,KAAK,MAAM,KAAK,KAAK,IAC9B,CAKA,QAAA,GACE,IAAI,EAAY,KAAK,QAAQ,MAAM,KAAK,KACpC,EAAY,KAAK,MAIrB,OAHoB,EAAU,OAAO,GACZ,KAAK,KAAK,IAGrC,EAGF,QAAQ,YAAc,YAStB,QAAQ,KAAQ,IACd,IAAI,EAAc,IAAI,YAEP,EAAQ,MAAM,KAAK,KACzB,SAAQ,GAAQ,EAAY,OAAO,KAE5C,IAAI,EAAW,EAAY,WAE3B,IAEE,OADQ,QAAQ,EAElB,CACA,MAAO,GACL,OAAO,IACT","file":"/npm/nodejs-project-folder@1.0.1/api.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/nodejs-project-folder@1.0.1/api.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","let Path = require('path');\n\n//-----------------------------\n\nclass PathBuilder {\n  constructor() {\n    this.rootDir = Path.resolve('.');\n    this.parts = [];\n  }\n\n  /**\n   * Changes the root directory from being the root project folder (top most folder) to being the current project's folder (closest project parent folder).\n   * Call this function if you are going to build a path for items in the current project and NOT the root project. (Avoids being affected when nested inside another project).\n   */\n  currentProjectAsRoot() {\n    let currentDir = __dirname;\n    let parentDir = Path.dirname(currentDir);\n    let parentName = parentDir.split(Path.sep).pop();\n\n    if (parentName == 'node_modules') {\n      let grandParentDir = Path.dirname(parentDir);\n      this.rootDir = grandParentDir;\n    }\n\n    return this;\n  }\n\n  /**\n   * Appends the directory name, file name, or partial path to the current path being built.\n   * @param {string} str Directory name, file name, or partial path.\n   */\n  append(str) {\n    if (str.includes(Path.sep)) {\n      let parts = str.split(Path.sep);\n\n      parts.forEach(p => {\n        if (p)\n          this.parts.push(p);\n      });\n    }\n    else\n      this.parts.push(str);\n\n    return this;\n  }\n\n  /**\n   * @returns {string} Returns the relative path.\n   */\n  relativePath() {\n    return this.parts.join(Path.sep);\n  }\n\n  /**\n   * @returns {string} Returns the full path.\n   */\n  fullPath() {\n    let rootParts = this.rootDir.split(Path.sep);\n    let pathParts = this.parts;\n    let combinedParts = rootParts.concat(pathParts);\n    let path = combinedParts.join(Path.sep);\n\n    return path;\n  }\n}\n\nexports.PathBuilder = PathBuilder;\n\n//-----------------------------------\n\n/**\n * Load the module at the specified relative path.\n * @param {string} relPath The relative path to the file in the root project.\n * @returns {object} Returns the respective module properties similar to using 'require'. Returns null if path does not exist or there is an error loading the module.\n */\nexports.Load = (relPath) => {\n  let pathBuilder = new PathBuilder();\n\n  let relParts = relPath.split(Path.sep);\n  relParts.forEach(part => pathBuilder.append(part));\n\n  let fullPath = pathBuilder.fullPath();\n\n  try {\n    let x = require(fullPath);\n    return x;\n  }\n  catch (error) {\n    return null;\n  }\n}"]}