{"version":3,"file":"destroy.cjs","sources":["../../../src/scripts/functions/destroy.ts"],"sourcesContent":["import { config } from '#scripts/constants';\nimport { getFolderPath } from '@bemedev/codebase/lib/helpers.js';\nimport edit, { type JsonEditor } from 'edit-json-file';\nimport { rmSync } from 'node:fs';\nimport { join } from 'node:path';\n\n/**\n * Supprime un fichier JSON ou un dossier de façon récursive.\n * @param targetPath Chemin absolu ou relatif du fichier ou dossier à supprimer\n */\nexport function destroy() {\n  const cwd = process.cwd();\n  const jsonPath = join(cwd, config.json);\n  let file: JsonEditor | undefined = edit(jsonPath);\n  const root = file?.get('path') as string | undefined;\n  if (root) {\n    const fullPath = getFolderPath(root);\n    try {\n      rmSync(fullPath, { recursive: true, force: true });\n      console.log(`Folder (\"${root}\") has been removed.`);\n    } catch {\n      console.error(`Error while removing the folder (\"${root}\").`);\n    }\n  }\n\n  file = undefined;\n  try {\n    rmSync(jsonPath, { force: true });\n    console.log(`Configuration file (\"${config.json}\") has been removed.`);\n  } catch {\n    console.error(\n      `Error while removing the configuration file (\"${config.json}\").`,\n    );\n  }\n}\n"],"names":["join","config","getFolderPath","rmSync"],"mappings":";;;;;;;;AAMA;;;AAGG;SACa,OAAO,GAAA;AACrB,IAAA,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE;IACzB,MAAM,QAAQ,GAAGA,SAAI,CAAC,GAAG,EAAEC,wBAAM,CAAC,IAAI,CAAC;AACvC,IAAA,IAAI,IAAI,GAA2B,IAAI,CAAC,QAAQ,CAAC;IACjD,MAAM,IAAI,GAAG,IAAI,EAAE,GAAG,CAAC,MAAM,CAAuB;IACpD,IAAI,IAAI,EAAE;AACR,QAAA,MAAM,QAAQ,GAAGC,wBAAa,CAAC,IAAI,CAAC;AACpC,QAAA,IAAI;AACF,YAAAC,SAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAClD,YAAA,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAA,oBAAA,CAAsB,CAAC;QACrD;AAAE,QAAA,MAAM;AACN,YAAA,OAAO,CAAC,KAAK,CAAC,qCAAqC,IAAI,CAAA,GAAA,CAAK,CAAC;QAC/D;IACF;IAEA,IAAI,GAAG,SAAS;AAChB,IAAA,IAAI;QACFA,SAAM,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACjC,OAAO,CAAC,GAAG,CAAC,CAAA,qBAAA,EAAwBF,wBAAM,CAAC,IAAI,CAAA,oBAAA,CAAsB,CAAC;IACxE;AAAE,IAAA,MAAM;QACN,OAAO,CAAC,KAAK,CACX,CAAA,8CAAA,EAAiDA,wBAAM,CAAC,IAAI,CAAA,GAAA,CAAK,CAClE;IACH;AACF;;;;"}