@@ -6,7 +6,6 @@ var util = require('hexo-util');
66var fs = require ( 'hexo-fs' ) ;
77var prettyHrtime = require ( 'pretty-hrtime' ) ;
88var crypto = require ( 'crypto' ) ;
9- var tildify = require ( 'tildify' ) ;
109var chalk = require ( 'chalk' ) ;
1110
1211var Pattern = util . Pattern ;
@@ -212,6 +211,8 @@ Box.prototype._handleUpdatedFile = function(path){
212211 self . bufferStore [ path ] = data . content ;
213212
214213 if ( ! cache ) {
214+ ctx . log . info ( 'Added: %s' , chalk . magenta ( id ) ) ;
215+
215216 return Cache . insert ( {
216217 _id : id ,
217218 checksum : checksum
@@ -220,11 +221,15 @@ Box.prototype._handleUpdatedFile = function(path){
220221 path : path
221222 } ) ;
222223 } else if ( cache . checksum === checksum ) {
224+ ctx . log . info ( 'Unchanged: %s' , chalk . magenta ( id ) ) ;
225+
223226 return {
224227 type : 'skip' ,
225228 path : path
226229 } ;
227230 } else {
231+ ctx . log . info ( 'Updated: %s' , chalk . magenta ( id ) ) ;
232+
228233 cache . checksum = checksum ;
229234 return cache . save ( ) . thenReturn ( {
230235 type : 'update' ,
@@ -246,6 +251,7 @@ Box.prototype._handleDeletedFile = function(path){
246251 var cache = Cache . findById ( id ) ;
247252 if ( ! cache ) return resolve ( ) ;
248253
254+ ctx . log . debug ( 'Deleted: %s' , chalk . magenta ( id ) ) ;
249255 return cache . remove ( ) . then ( resolve , reject ) ;
250256 } ) . thenReturn ( {
251257 type : 'delete' ,
@@ -350,24 +356,17 @@ Box.prototype.watch = function(callback){
350356 self . watcher = watcher ;
351357
352358 watcher . on ( 'add' , function ( path ) {
353- log . info ( 'Added: %s' , displayPath ( path ) ) ;
354359 self . _handleUpdatedFile ( getPath ( path ) ) . then ( dispatch ) ;
355360 } ) . on ( 'change' , function ( path ) {
356- log . info ( 'Updated: %s' , displayPath ( path ) ) ;
357361 self . _handleUpdatedFile ( getPath ( path ) ) . then ( dispatch ) ;
358362 } ) . on ( 'unlink' , function ( path ) {
359- log . info ( 'Deleted: %s' , displayPath ( path ) ) ;
360363 self . _handleDeletedFile ( getPath ( path ) ) . then ( dispatch ) ;
361364 } ) ;
362365
363366 return watcher ;
364367 } ) . nodeify ( callback ) ;
365368} ;
366369
367- function displayPath ( path ) {
368- return chalk . magenta ( tildify ( path ) ) ;
369- }
370-
371370Box . prototype . unwatch = function ( ) {
372371 if ( ! this . watcher ) throw new Error ( 'Watcher hasn\'t started yet.' ) ;
373372
0 commit comments