{"version":3,"file":"filepath-to-prop-path.mjs","sources":["../../src/utils/filepath-to-prop-path.ts"],"sourcesContent":["import path from 'node:path';\nimport fp from 'lodash/fp';\n\n/**\n * Returns a path (as an array) from a file path\n */\nexport const filePathToPropPath = (\n entryPath: string,\n useFileNameAsKey: boolean = true\n): string[] => {\n const transform = fp.pipe(\n // Remove the relative path prefixes: './' for posix (and some win32) and \".\\\" for win32\n removeRelativePrefix,\n // Remove the path metadata and extensions\n fp.replace(/(\\.settings|\\.json|\\.js)/g, ''),\n // Transform to lowercase\n // Note: We're using fp.toLower instead of fp.lowercase as the latest removes special characters such as \"/\"\n fp.toLower,\n // Split the cleaned path by matching every possible separator (either \"/\" or \"\\\" depending on the OS)\n fp.split(new RegExp(`[\\\\${path.win32.sep}|${path.posix.sep}]`, 'g')),\n // Make sure to remove leading '.' from the different path parts\n fp.map(fp.trimCharsStart('.')),\n // join + split in case some '.' characters are still present in different parts of the path\n fp.join('.'),\n fp.split('.'),\n // Remove the last portion of the path array if the file name shouldn't be used as a key\n useFileNameAsKey ? fp.identity : fp.slice(0, -1)\n );\n\n return transform(entryPath) as string[];\n};\n\nconst removeRelativePrefix = (filePath: string) => {\n return filePath.startsWith(`.${path.win32.sep}`) || filePath.startsWith(`.${path.posix.sep}`)\n ? filePath.slice(2)\n : filePath;\n};\n"],"names":["filePathToPropPath","entryPath","useFileNameAsKey","transform","fp","pipe","removeRelativePrefix","replace","toLower","split","RegExp","path","win32","sep","posix","map","trimCharsStart","join","identity","slice","filePath","startsWith"],"mappings":";;;AAGA;;AAEC,IACYA,MAAAA,kBAAAA,GAAqB,CAChCC,SAAAA,EACAC,mBAA4B,IAAI,GAAA;AAEhC,IAAA,MAAMC,SAAYC,GAAAA,EAAAA,CAAGC,IAAI;AAEvBC,IAAAA,oBAAAA;AAEAF,IAAAA,EAAAA,CAAGG,OAAO,CAAC,2BAA6B,EAAA,EAAA,CAAA;;IAGxCH,EAAGI,CAAAA,OAAO;IAEVJ,EAAGK,CAAAA,KAAK,CAAC,IAAIC,MAAAA,CAAO,CAAC,GAAG,EAAEC,IAAKC,CAAAA,KAAK,CAACC,GAAG,CAAC,CAAC,EAAEF,IAAKG,CAAAA,KAAK,CAACD,GAAG,CAAC,CAAC,CAAC,EAAE,GAAA,CAAA,CAAA;AAE/DT,IAAAA,EAAAA,CAAGW,GAAG,CAACX,EAAAA,CAAGY,cAAc,CAAC;AAEzBZ,IAAAA,EAAAA,CAAGa,IAAI,CAAC,GAAA,CAAA,EACRb,GAAGK,KAAK,CAAC;AAETP,IAAAA,gBAAAA,GAAmBE,GAAGc,QAAQ,GAAGd,GAAGe,KAAK,CAAC,GAAG,CAAC,CAAA,CAAA,CAAA;AAGhD,IAAA,OAAOhB,SAAUF,CAAAA,SAAAA,CAAAA;AACnB;AAEA,MAAMK,uBAAuB,CAACc,QAAAA,GAAAA;AAC5B,IAAA,OAAOA,QAASC,CAAAA,UAAU,CAAC,CAAC,CAAC,EAAEV,IAAKC,CAAAA,KAAK,CAACC,GAAG,CAAC,CAAC,CAAKO,IAAAA,QAAAA,CAASC,UAAU,CAAC,CAAC,CAAC,EAAEV,IAAAA,CAAKG,KAAK,CAACD,GAAG,CAAC,CAAC,CAAA,GACxFO,QAASD,CAAAA,KAAK,CAAC,CACfC,CAAAA,GAAAA,QAAAA;AACN,CAAA;;;;"}