sintaxi / harp

Static Web Server/Generator/Bundler
http://harpjs.com
5k stars 342 forks source link

formatting errors #605

Closed dcsan closed 4 years ago

dcsan commented 7 years ago

for some reason output errors are in unreadable JSON with \n instead of formatted text is there a way to change this default? harp -h yields nothing

{
  "source": "Jade",
  "dest": "HTML",
  "filename": "/Users/dc/dev/rikai/rikai.co/harp-site/public/partials/_section_services.jade",
  "lineno": 8,
  "name": "TypeError",
  "message": "/Users/dc/dev/rikai/rikai.co/harp-site/public/index.jade:8\n    6|     != partial('partials/_nav')\r\n    7|     != partial('partials/_header')\r\n  > 8|     != partial('partials/_section_services')\r\n    9|     != partial('partials/_section_casestudies')\r\n    10|     //!= partial('partials/_section_clients')\r\n    11|     != partial('partials/_section_news')\r\n\nCannot read property '_data' of undefined",
  "stack": "// Services Section\r\nsection#services\r\n  .container\r\n    col-lg-12.text-center\r\n      h2.section-heading Chatbots are the best way to\r\n      h3.section-subheading.text-muted= text\r\n    .row.text-center\r\n      each serviceItem in public.services._data.items\r\n        .col-md-4.text-center\r\n          span.fa-stack.fa-4x\r\n            i.fa.fa-circle.fa-stack-2x.text-primary\r\n            i.fa.fa-stack-1x.fa-inverse(class=serviceItem.icon)\r\n          h4.service-heading= serviceItem.title\r\n          .col-lg-12.text-left\r\n              ul.text-muted\r\n                = serviceItem.description1\r\n                h4.text-muted\r\n              ul.text-muted\r\n                = serviceItem.description2\r\n                h4.text-muted\r\n              ul.text-muted\r\n                = serviceItem.description3\r\n                h4.text-muted\r\n              ul.text-muted\r\n                = serviceItem.description4\r\n                h4.text-muted\r\n  h3.section-subheading\r\n  .col-lg-14.text-center\r\n    != partial('_services_description')\r\n",
  "path": "/Users/dc/dev/rikai/rikai.co/harp-site/public/index.jade"
}
mattsalt commented 7 years ago

I had the same problem. The errors were annoying me in this format so I tweaked the compile command in bin/harp.js. I replaced line 148 console.log(JSON.stringify(errors, null, 2) with console.log(JSON.stringify(errors, null, 2) .replace(/\\n/g, "\n"))

and now my errors are a little easier to read (in my opinion).

 { 
      "source": "Jade",
      "dest": "HTML",
      "filename": "C:\\dev\\git\\harptest\\_layout.jade",
      "lineno": 4,
      "name": "Error",
      "message": "Matt's Jade error",
      "stack": "doctype
    html
      head
        link(rel=\"stylesheet\" href=\"/main.css\"
      body
        != yield
   "
}