|
1 | 1 | #!/usr/bin/env node |
2 | 2 | 'use strict'; |
3 | 3 |
|
4 | | -var colors = require('colors'), |
5 | | - server = require('fast-http'), |
| 4 | +var server = require('fast-http'), |
6 | 5 | opn = require('opn'), |
7 | | - path = require('path'), |
8 | | - fs = require('fs'), |
9 | 6 | program = require('commander'), |
10 | | - nodemon = require('nodemon'), |
11 | 7 | port = 80, |
12 | 8 | test = require('net').createServer(); |
13 | 9 |
|
14 | 10 | program |
15 | 11 | .version(require('./package.json').version) |
16 | 12 | .option('-p, --port [number]', 'specified the port') |
17 | 13 | .option('-o, --open', 'open in the browser') |
18 | | - .option('-n, --nodemon', 'use nodemon with your node project') |
| 14 | + .option('-w, --wordy', 'specified if it\'ll log all request') |
19 | 15 | .parse(process.argv); |
20 | 16 |
|
21 | 17 | if (!isNaN(parseFloat(program.port)) && isFinite(program.port)){ |
22 | 18 | port = program.port; |
23 | 19 | } |
24 | 20 |
|
25 | 21 | test.once('error', function(err) { |
26 | | - console.log('\n\'' + 'fast-http'.cyan + '\':' + 'This port is already used!\n'.red); |
| 22 | + console.log('This port is already used!'); |
27 | 23 | process.exit(1); |
28 | 24 | }); |
29 | 25 |
|
30 | 26 | test.once('listening', function() { |
31 | 27 | test.close(); |
32 | | - if (program.nodemon) { |
33 | | - nodemon({ |
34 | | - script: require(process.cwd() + '/package.json').main, |
35 | | - ext: 'js json', |
36 | | - ignore: 'vendor' |
37 | | - }); |
38 | | - nodemon.on('start', function () { |
39 | | - console.log('\'' + 'nodemon'.cyan + '\': App has started.\n'); |
40 | | - }).on('quit', function () { |
41 | | - console.log('\n\'' + 'nodemon'.cyan + '\': App has quit.\n'); |
42 | | - }).on('restart', function (files) { |
43 | | - console.log('\n\'' + 'nodemon'.cyan + '\': App restarted due to: ' + files); |
44 | | - }); |
45 | | - } else { |
46 | | - server(port, process.cwd()); |
47 | | - } |
| 28 | + |
| 29 | + server(port, process.cwd(), program.wordy); |
| 30 | + |
48 | 31 |
|
49 | 32 | if (program.open){ |
50 | 33 | opn('http://localhost:' + port); |
51 | 34 | } |
52 | | - |
53 | | - require('fb-flo')( |
54 | | - process.cwd(), |
55 | | - { |
56 | | - port: 8888, |
57 | | - host: 'localhost', |
58 | | - verbose: false, |
59 | | - glob: [ |
60 | | - '**/*.js', |
61 | | - '**/*.css', |
62 | | - '**/*.html' |
63 | | - ] |
64 | | - }, |
65 | | - function resolver(filepath, callback) { |
66 | | - callback({ |
67 | | - resourceURL: path.extname(filepath), |
68 | | - contents: fs.readFileSync(filepath), |
69 | | - reload: true, |
70 | | - update: function(_window, _resourceURL) { |
71 | | - console.log('Resource ' + _resourceURL + ' has just been updated with new content'); |
72 | | - } |
73 | | - }); |
74 | | - } |
75 | | - ); |
76 | 35 | }); |
77 | 36 |
|
78 | 37 | test.listen(port); |
0 commit comments