Skip to content

Commit

Permalink
feat: improve packaging and exports
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Oct 8, 2018
1 parent 73bdd1a commit 90da862
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"release": "standard-version && yarn build && git push --follow-tags && npm publish"
},
"files": [
"dist"
"dist",
"src"
],
"keywords": [
"console",
Expand Down
25 changes: 19 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import env from 'std-env'
import Consola from './consola'
import Reporters from './reporters'
import {
BasicReporter,
FancyReporter,
JSONReporter,
WinstonReporter
} from './reporters'

// Attach consola to the global to prevent
// duplicated instances when used with different packages/versions
Expand All @@ -16,18 +21,26 @@ if (!consola || Consola.prototype.__VERSION__ !== otherVersion) {
})

if (env.minimalCLI) {
consola.add(new Reporters.BasicReporter())
consola.add(new BasicReporter())
} else {
consola.add(new Reporters.FancyReporter())
consola.add(new FancyReporter())
}

Object.assign(consola, { Consola }, Reporters)
Object.assign(consola, {
Consola,
BasicReporter,
FancyReporter,
JSONReporter,
WinstonReporter
})

global.consola = consola
if (typeof global !== 'undefined') {
global.consola = consola
}

if (otherVersion) {
consola.warn(
'Multiply versions of consola found!',
'Different versions of consola found!',
`${otherVersion} replaced by ${consola.__VERSION__}`
)
}
Expand Down
15 changes: 4 additions & 11 deletions src/reporters/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import BasicReporter from './basic'
import FancyReporter from './fancy'
import JSONReporter from './json'
import WinstonReporter from './winston'

export default {
BasicReporter,
FancyReporter,
JSONReporter,
WinstonReporter
}
export { default as BasicReporter } from './basic'
export { default as FancyReporter } from './fancy'
export { default as JSONReporter } from './json'
export { default as WinstonReporter } from './winston'

0 comments on commit 90da862

Please sign in to comment.