Skip to content

Commit f662025

Browse files
committed
tasks: merge format bundle make watchified bundle script
- format bundle does not make sense in a non-watchify context
1 parent d5cb921 commit f662025

File tree

2 files changed

+33
-41
lines changed

2 files changed

+33
-41
lines changed

tasks/util/format_bundle_msg.js

Lines changed: 0 additions & 39 deletions
This file was deleted.

tasks/util/make_watchified_bundle.js renamed to tasks/util/watchified_bundle.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ var fs = require('fs');
22

33
var browserify = require('browserify');
44
var watchify = require('watchify');
5+
var prettySize = require('prettysize');
56

6-
var compressAttributes = require('./compress_attributes');
7-
var formatBundleMsg = require('./format_bundle_msg');
87
var constants = require('./constants');
8+
var compressAttributes = require('./compress_attributes');
99

1010
/**
1111
* Make a plotly.js browserify bundle function watched by watchify.
@@ -56,3 +56,34 @@ module.exports = function makeWatchifiedBundle(onFirstBundleCallback) {
5656

5757
return bundle;
5858
};
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-Za-z\s].*)\)/)[1];
86+
87+
console.log(msgParts.join(' '));
88+
});
89+
}

0 commit comments

Comments
 (0)