1 | "use strict";
|
2 |
|
3 | const version = require('../package.json').version;
|
4 | const leftPad = require('left-pad');
|
5 | const Packer = require('./Packer');
|
6 | const validateOption = require('./validateOption');
|
7 |
|
8 | function getPacker(option) {
|
9 | validateOption(option);
|
10 | return new Packer(option)
|
11 | }
|
12 |
|
13 | const freepack = (option, callback) => {
|
14 | const packer = getPacker(option);
|
15 |
|
16 | console.log(packer.option)
|
17 | console.log(packer.dirs)
|
18 |
|
19 | packer.clean();
|
20 |
|
21 | packer.run(() => {
|
22 | const time = packer.time.get();
|
23 | console.log('='.repeat(24));
|
24 | console.log(`${leftPad('Time Used:', 12)} ${time.total}ms`);
|
25 | console.log('-'.repeat(24));
|
26 | time.children.forEach(t => {
|
27 | console.log(`${leftPad(t[0] + ':', 12)} ${t[1]}ms`);
|
28 | });
|
29 | console.log('='.repeat(24));
|
30 |
|
31 | callback();
|
32 | });
|
33 |
|
34 | return packer;
|
35 | };
|
36 |
|
37 | exports = module.exports = freepack;
|
38 |
|
39 |
|
40 | freepack.diff = (option, callback) => {
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 | };
|
47 |
|
48 | freepack.test = (option, callback) => {
|
49 | const packer = getPacker(option);
|
50 |
|
51 | packer.clean();
|
52 |
|
53 | packer.init();
|
54 | packer.diff();
|
55 | packer.match();
|
56 |
|
57 | packer.clean();
|
58 |
|
59 | return packer;
|
60 | };
|
61 |
|
62 | freepack.packer = getPacker;
|