UNPKG

@utopia-utils/cli

Version:
1 lines 2.51 kB
{"version":3,"file":"index.mjs","names":["CACHE_DIR: string","path: string","path","path: string","path","path: string","path"],"sources":["../src/constant.ts","../src/getGitCommitHash.ts","../src/isDirector.ts","../src/isFile.ts","../src/pathExists.ts"],"sourcesContent":["import path from 'node:path'\n\n/** The path to the node_modules cache directory. */\nexport const CACHE_DIR: string = path.resolve(process.cwd(), 'node_modules/.cache')\n","import { execSync } from 'node:child_process'\n\n/**\n * return the current commit hash\n * @returns The git commit hash\n */\nexport function getGitCommitHash(): string | undefined {\n try {\n const hash = execSync('git rev-parse --short HEAD').toString().replace('\\n', '').trim()\n if (hash === 'undefined')\n throw new Error('Could not retrieve git commit hash.')\n return hash\n }\n catch {\n console.error('Could not retrieve git commit hash.')\n }\n}\n","import fs from 'node:fs/promises'\n\nexport async function isDirector(path: string): Promise<boolean> {\n try {\n const stat = await fs.stat(path)\n return stat.isDirectory()\n }\n catch {\n return false\n }\n}\n","import fs from 'node:fs/promises'\n\n/**\n * It returns true if the path is a file, and false if it's not\n * @param {string} path - The path to the file to check.\n * @returns A boolean value.\n */\nexport async function isFile(path: string): Promise<boolean> {\n try {\n const stat = await fs.stat(path)\n return stat.isFile()\n }\n catch {\n return false\n }\n}\n","import { access } from 'node:fs/promises'\n\n/**\n * It returns true if the path exists, and false if it doesn't\n * @param {string} path - The path to check.\n * @returns A promise that resolves to a boolean.\n */\nexport async function pathExists(path: string): Promise<boolean> {\n try {\n await access(path)\n return true\n }\n catch {\n return false\n }\n}\n"],"mappings":"oHAGA,MAAaA,EAAoB,EAAK,QAAQ,QAAQ,KAAK,CAAE,sBAAsB,CCGnF,SAAgB,GAAuC,CACrD,GAAI,CACF,IAAM,EAAO,EAAS,6BAA6B,CAAC,UAAU,CAAC,QAAQ;EAAM,GAAG,CAAC,MAAM,CACvF,GAAI,IAAS,YACX,KAAM,CAAI,MAAM,sCAAA,CAClB,OAAO,CACR,MACK,CACJ,QAAQ,MAAM,sCAAsC,AACrD,CACF,CCdD,eAAsB,EAAWK,EAAgC,CAC/D,GAAI,CACF,IAAM,EAAO,KAAM,GAAG,KAAKC,EAAK,CAChC,MAAO,GAAK,aAAa,AAC1B,MACK,CACJ,OAAO,CACR,CACF,CCHD,eAAsB,EAAOD,EAAgC,CAC3D,GAAI,CACF,IAAM,EAAO,KAAM,GAAG,KAAKC,EAAK,CAChC,MAAO,GAAK,QAAQ,AACrB,MACK,CACJ,OAAO,CACR,CACF,CCRD,eAAsB,EAAWD,EAAgC,CAC/D,GAAI,CAEF,OADA,KAAM,GAAOC,EAAK,EACX,CACR,MACK,CACJ,OAAO,CACR,CACF"}