File tree Expand file tree Collapse file tree 3 files changed +45
-12
lines changed
Expand file tree Collapse file tree 3 files changed +45
-12
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,7 @@ local function testAll()
6666 test ' document_symbol'
6767 test ' code_action'
6868 test ' type_formatting'
69- -- test 'other'
69+ test ' other'
7070end
7171
7272local files = require " files"
Original file line number Diff line number Diff line change 1+ local thread = require ' bee.thread'
2+ local fw = require ' filewatch'
3+ local fs = require ' bee.filesystem'
4+ local fsu = require ' fs-utility'
5+
6+ local path = fs .path (LOGPATH ) / ' fw'
7+
8+ fs .create_directories (path )
9+
10+ os.remove ((path / ' test.txt' ):string ())
11+
12+ local _ <close> = fw .watch (path :string ())
13+ fsu .saveFile (path / ' test.txt' , ' test' )
14+
15+ local events
16+ fw .event (function (ev , filename )
17+ events [# events + 1 ] = {ev , filename }
18+ end )
19+
20+ thread .sleep (1 )
21+ events = {}
22+ fw .update ()
23+ assert (# events == 1 )
24+ assert (events [1 ][1 ] == ' create' )
25+
26+ fsu .saveFile (path / ' test.txt' , ' modify' )
27+
28+ thread .sleep (1 )
29+ events = {}
30+ fw .update ()
31+ assert (# events == 1 )
32+ assert (events [1 ][1 ] == ' change' )
33+
34+ local f <close> = io.open ((path / ' test.txt' ):string (), ' a' )
35+ assert (f )
36+ f :write (' xxx' )
37+ f :flush ()
38+
39+ thread .sleep (1 )
40+ events = {}
41+ fw .update ()
42+ assert (# events == 1 )
43+ assert (events [1 ][1 ] == ' change' )
Original file line number Diff line number Diff line change 1- local fs = require ' bee.filesystem'
2- local platform = require ' bee.platform'
3- local path = fs .path ' /a/b/c/d/e/../../../..'
4- local absolute = fs .absolute (path )
5- if platform .OS == ' Windows' then
6- assert (absolute :string ():sub (- 2 ) == ' /a' , absolute :string ())
7- elseif platform .OS == ' Linux' then
8- assert (absolute :string ():sub (- 3 ) == ' /a/' , absolute :string ())
9- elseif platform .OS == ' macOS' then
10- -- 不支持
11- end
1+ require ' other.filewatch'
You can’t perform that action at this time.
0 commit comments