@@ -2,10 +2,10 @@ var fs = require('fs');
2
2
3
3
var browserify = require ( 'browserify' ) ;
4
4
var watchify = require ( 'watchify' ) ;
5
+ var prettySize = require ( 'prettysize' ) ;
5
6
6
- var compressAttributes = require ( './compress_attributes' ) ;
7
- var formatBundleMsg = require ( './format_bundle_msg' ) ;
8
7
var constants = require ( './constants' ) ;
8
+ var compressAttributes = require ( './compress_attributes' ) ;
9
9
10
10
/**
11
11
* Make a plotly.js browserify bundle function watched by watchify.
@@ -56,3 +56,34 @@ module.exports = function makeWatchifiedBundle(onFirstBundleCallback) {
56
56
57
57
return bundle ;
58
58
} ;
59
+
60
+ function formatBundleMsg ( b , bundleName ) {
61
+ var msgParts = [
62
+ bundleName , ':' , '' ,
63
+ 'written' , 'in' , '' , 'sec' ,
64
+ '[' , '' , '' , '' , ']'
65
+ ] ;
66
+
67
+ b . on ( 'bytes' , function ( bytes ) {
68
+ msgParts [ 2 ] = prettySize ( bytes , true ) ;
69
+ } ) ;
70
+
71
+ b . on ( 'time' , function ( time ) {
72
+ msgParts [ 5 ] = ( time / 1000 ) . toFixed ( 2 ) ;
73
+ } ) ;
74
+
75
+ b . on ( 'log' , function ( ) {
76
+ var date = new Date ( ) ;
77
+
78
+ // get locale date
79
+ msgParts [ msgParts . length - 4 ] = date . toLocaleDateString ( ) ;
80
+
81
+ // get locale time
82
+ msgParts [ msgParts . length - 3 ] = date . toLocaleTimeString ( ) ;
83
+
84
+ // get time zone code
85
+ msgParts [ msgParts . length - 2 ] = date . toString ( ) . match ( / \( ( [ A - Z a - z \s ] .* ) \) / ) [ 1 ] ;
86
+
87
+ console . log ( msgParts . join ( ' ' ) ) ;
88
+ } ) ;
89
+ }
0 commit comments