@@ -9,6 +9,7 @@ var server = require('../src')
9
9
10
10
updateNotifier ( { packageName : pkg . name , packageVersion : pkg . version } ) . notify ( )
11
11
12
+ // Parse arguments
12
13
var argv = yargs
13
14
. usage ( '$0 <source>' )
14
15
. help ( 'help' ) . alias ( 'help' , 'h' )
@@ -26,33 +27,40 @@ var argv = yargs
26
27
. require ( 1 , 'Missing <source> argument' )
27
28
. argv
28
29
30
+ // Start server function
29
31
function start ( object , filename ) {
30
32
for ( var prop in object ) {
31
- console . log ( ' http://localhost:' + port + '/' + chalk . green ( prop ) )
33
+ console . log ( chalk . grey ( ' http://localhost:' + port + '/' ) + chalk . cyan ( prop ) )
32
34
}
33
35
34
36
console . log (
35
- '\nEnter ' + chalk . green ( '`s`' ) + ' at any time to create a snapshot of the db\n'
37
+ '\nYou can now go to ' + chalk . grey ( 'http://localhost:' + port + '/\n' )
38
+ )
39
+
40
+ console . log (
41
+ 'Enter ' + chalk . cyan ( '`s`' ) + ' at any time to create a snapshot of the db\n'
36
42
)
37
43
38
44
process . stdin . resume ( )
39
45
process . stdin . setEncoding ( 'utf8' )
40
46
process . stdin . on ( 'data' , function ( chunk ) {
41
47
if ( chunk . trim ( ) . toLowerCase ( ) === 's' ) {
42
48
var file = 'db-' + Date . now ( ) + '.json'
43
- _db . save ( object , filename )
44
- console . log ( '\nSaved snapshot to ' + chalk . green ( file ) + '\n' )
49
+ _db . save ( object , file )
50
+ console . log ( '\nSaved snapshot to ' + chalk . cyan ( file ) + '\n' )
45
51
}
46
52
} )
47
53
48
54
server ( object , filename ) . listen ( port )
49
55
}
50
56
57
+ // Set file and port
51
58
var source = argv . _ [ 0 ]
52
59
var port = process . env . PORT || argv . port
53
60
54
- console . log ( chalk . green ( '\n{^ ^} Yo!\n' ) )
55
- console . log ( 'Loading database from ' + source + '\n' )
61
+ // Say hi, load file and start server
62
+ console . log ( chalk . cyan ( '{^_^} Hi!\n' ) )
63
+ console . log ( 'Loading database from ' + chalk . cyan ( source ) )
56
64
57
65
if ( / \. j s o n $ / . test ( source ) ) {
58
66
var filename = process . cwd ( ) + '/' + source
0 commit comments