File tree 2 files changed +12
-9
lines changed
2 files changed +12
-9
lines changed Original file line number Diff line number Diff line change 8
8
"browser" : " dist/consola.browser.js" ,
9
9
"typings" : " types/consola.d.ts" ,
10
10
"scripts" : {
11
- "build" : " rm -rf dist && yarn build:cjs && yarn build:browser && rm dist/*.map" ,
12
- "build:cjs " : " bili --file-name consola.js --format cjs --bundle-node-modules --minify src/index .js" ,
11
+ "build" : " rm -rf dist && yarn build:node && yarn build:browser && rm dist/*.map" ,
12
+ "build:node " : " bili --file-name consola.js --format cjs --bundle-node-modules --minify src/node .js" ,
13
13
"build:browser" : " bili --file-name consola.browser.js --format umd --module-name consola --bundle-node-modules --minify src/browser.js" ,
14
14
"demo" : " node demo" ,
15
15
"browser" : " serve" ,
21
21
},
22
22
"files" : [
23
23
" dist" ,
24
- " consola.js" ,
25
24
" types"
26
25
],
27
26
"keywords" : [
Original file line number Diff line number Diff line change 1
- if ( global . consola ) {
2
- module . exports = global . consola
3
- } else {
4
- const env = require ( 'std-env' )
5
- const { Consola, BasicReporter, FancyReporter } = require ( './dist/consola.js' )
1
+ import env from 'std-env'
2
+ import { Consola , BasicReporter , FancyReporter } from '.'
6
3
4
+ function createConsola ( ) {
7
5
// Log level
8
6
let level = env . debug ? 4 : 3
9
7
if ( process . env [ 'CONSOLA_LEVEL' ] ) {
10
8
level = parseInt ( process . env [ 'CONSOLA_LEVEL' ] ) || level
11
9
}
12
10
13
11
// Create new consola instance
14
- module . exports = global . consola = new Consola ( {
12
+ return new Consola ( {
15
13
level,
16
14
reporters : [
17
15
( env . ci || env . test )
@@ -20,3 +18,9 @@ if (global.consola) {
20
18
]
21
19
} )
22
20
}
21
+
22
+ if ( ! global . consola ) {
23
+ global . consola = createConsola ( )
24
+ }
25
+
26
+ export default global . consola
You can’t perform that action at this time.
0 commit comments