Permalink
Browse files

Move logic into core module

  • Loading branch information...
Kikobeats committed Jul 9, 2018
1 parent e160be6 commit 036b1ab6039af169c74f9e6bcdb0331eb37a832e
Showing with 16 additions and 43 deletions.
  1. +0 −19 bin/cli/extract-urls.js
  2. +0 −9 bin/cli/get-error.js
  3. +4 −9 bin/cli/index.js
  4. +10 −1 bin/cli/{render-error.js → pretty-error.js}
  5. +2 −5 package.json

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -8,10 +8,8 @@ const { first, size, concat, isEmpty } = require('lodash')
const urlint = require('@urlint/core')
const { ci } = require('ci-env')
const extractUrls = require('./extract-urls')
const renderError = require('./render-error')
const prettyError = require('./pretty-error')
const pkg = require('../../package.json')
const getError = require('./get-error')
const getUrl = require('./get-url')
const build = require('./build')
const view = require('../view')
@@ -89,13 +87,10 @@ const cli = require('meow')(require('./help'), {
}
await build.start()
const urls = await extractUrls(url, opts)
const emitter = await urlint(urls, opts)
view({ total: size(urls), emitter, ...opts })
const emitter = await urlint(url, opts)
view({ total: size(url), emitter, ...opts })
} catch (genericError) {
const error = getError(genericError)
const prettyError = renderError(error)
console.log(prettyError)
console.log(prettyError(genericError))
await build.exit({ buildCode: 1, exitCode: 1 })
}
})()
@@ -2,6 +2,7 @@
const PrettyError = require('pretty-error')
const cleanStack = require('clean-stack')
const { chain } = require('lodash')
const pe = new PrettyError()
@@ -38,8 +39,16 @@ pe.appendStyle({
}
})
module.exports = error => {
const renderError = error => {
const stack = cleanStack(error.stack)
const cleanError = Object.assign({}, error, { stack })
return pe.render(cleanError)
}
module.exports = genericError => {
const error = chain(genericError)
.castArray()
.first()
.value()
return renderError(error)
}
@@ -34,23 +34,20 @@
"dependencies": {
"@urlint/core": "~1.3.5",
"chalk": "~2.4.1",
"cheerio": "~1.0.0-rc.2",
"ci-env": "~1.6.1",
"clean-stack": "~1.3.0",
"cosmiconfig": "~5.0.5",
"github-build": "~1.2.0",
"html-get": "~1.0.7",
"html-urls": "~2.1.0",
"lodash": "~4.17.10",
"meow": "~5.0.0",
"neat-log": "~3.0.1",
"normalize-url": "~3.1.0",
"ora": "~2.1.0",
"pretty-error": "~2.1.1",
"pretty-ms": "~3.2.0",
"puppeteer": "~1.5.0",
"reachable-url": "~1.1.2",
"update-notifier": "~2.5.0",
"xml-urls": "~1.0.3"
"update-notifier": "~2.5.0"
},
"devDependencies": {
"ava": "latest",

0 comments on commit 036b1ab

Please sign in to comment.