{"version":3,"sources":["jsdelivr-header.js","/npm/html-to-text-cli@0.0.1/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;ACLA,MAAM,GAAK,QAAQ,MACb,KAAO,QAAQ,QACf,SAAW,QAAQ,YACnB,MAAQ,QAAQ,SAChB,WAAa,QAAQ,sBAErB,IAAM,QAAQ,IAOpB,WAAc,IACZ,IACE,OAAO,GAAG,SAAS,GAAM,UAAmC,UAAvB,KAAK,QAAQ,EACpD,CAAE,MAAO,GAEP,OADA,QAAQ,IAAI,MAAM,IAAI,mCACf,CACT,GAGF,YAAc,IAeL,SAAS,OAdA,CACd,CACE,KAAM,OACN,KAAM,QACN,QAAS,+BACT,SAAW,KACL,EAAM,QAGD,8CAQjB,KAAO,UACL,IACE,MAAM,QAAa,cACnB,GAAI,WAAW,EAAK,MAAO,CACzB,MAAM,EAAY,EAAK,KAAK,MAAM,KAClC,IAAI,MAAM,MAAM,mBAChB,IAAI,MAAM,0BAA0B,MAAM,UAAU,KAAK,EAAK,sCAAsC,MAAM,UAAU,KAAK,EAAU,GAAK,YACxI,MAAM,QAAiB,GAAG,aAAa,EAAK,KAAM,QAC5C,QAAa,WAAW,GAE9B,GAAG,UAAU,EAAU,GAAK,OAAQ,GAAO,IACrC,GAAK,IAAI,MAAM,IAAI,2BACvB,IAAI,MAAM,MAAM,wBAAwB,MAAM,UAAU,KAAK,EAAU,GAAK,WAAW,GAE3F,CACF,CAAE,MAAO,GACP,QAAQ,IAAI,MAAM,IAAI,yBACxB,GAIF","file":"/npm/html-to-text-cli@0.0.1/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/html-to-text-cli@0.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","#! /usr/bin/env node\nconst fs = require('fs');\nconst path = require('path');\nconst inquirer = require('inquirer');\nconst chalk = require('chalk');\nconst htmlToText = require('html-email-to-text');\n\nconst log = console.log;\n\n// Define some helper functions\n\n// Check that the file exists, if it does exist then the\n// programme may proceed, else kill it and alert the user\n// via a prompt in the terminal.\nfileExists = (file) => {\n  try {\n    return fs.statSync(file).isFile() && path.extname(file) === '.html';\n  } catch (err) {\n    console.log(chalk.red('❗   That ain\\'t no HTML file ❗'))\n    return false;\n  }\n}\n\ngetFilePath = () => {\n  const getPath = [\n    {\n      name: 'file',\n      type: 'input',\n      message: 'Gimme the path to your file:',\n      validate: (value) => {\n        if (value.length) {\n          return true;\n        } else {\n          return 'Hmm.. that doesn\\'t seem right, try again'\n        }\n      }\n    }\n  ];\n  return inquirer.prompt(getPath);\n}\n\ninit = async () => {\n  try {\n    const file = await getFilePath();\n    if (fileExists(file.file)) {\n      const fileArray = file.file.split('.');\n      log(chalk.green('Let\\'s do this!'));\n      log(chalk(`We're going to convert ${chalk.underline.bold(file.file)} and create a new file called ${chalk.underline.bold(fileArray[0] + '.txt')}`));\n      const contents = await fs.readFileSync(file.file, 'utf8');\n      const text = await htmlToText(contents);\n\n      fs.writeFile(fileArray[0] + '.txt', text, (err) => {\n        if (err) log(chalk.red('Something wen\\'t wrong!'));\n        log(chalk.green(`Successfully created ${chalk.underline.bold(fileArray[0] + '.txt')}`));\n      });\n    }\n  } catch (err) {\n    console.log(chalk.red('Something wen\\'t wrong'));\n  }\n}\n\n// Let's do this\ninit();"]}