@@ -2,12 +2,17 @@ var path = require('path'),
2
2
fs = require ( 'fs' ) ,
3
3
sys = require ( 'util' ) ;
4
4
5
+ var readDirFilesSync = function ( dir , regex , callback ) {
6
+ fs . readdirSync ( dir ) . forEach ( function ( file ) {
7
+ if ( ! regex . test ( file ) ) { return ; }
8
+ callback ( file ) ;
9
+ } ) ;
10
+ }
11
+
5
12
var createTestRunnerPage = function ( dir , exclude , testSuiteName , dir2 ) {
6
13
var output = '<html><head>\n' ;
7
14
8
- fs . readdirSync ( path . join ( "test" , dir , 'less' , dir2 || "" ) ) . forEach ( function ( file ) {
9
- if ( ! / \. l e s s / . test ( file ) ) { return ; }
10
-
15
+ readDirFilesSync ( path . join ( "test" , dir , 'less' , dir2 || "" ) , / \. l e s s $ / , function ( file ) {
11
16
var name = path . basename ( file , '.less' ) ,
12
17
id = ( dir ? dir + '-' : "" ) + 'less-' + ( dir2 ? dir2 + "-" : "" ) + name ;
13
18
@@ -22,6 +27,15 @@ var createTestRunnerPage = function(dir, exclude, testSuiteName, dir2) {
22
27
fs . writeFileSync ( path . join ( 'test/browser' , 'test-runner-' + testSuiteName + '.htm' ) , output ) ;
23
28
} ;
24
29
30
+ var removeFiles = function ( dir , regex ) {
31
+ readDirFilesSync ( dir , regex , function ( file ) {
32
+ fs . unlinkSync ( path . join ( dir , file ) , function ( ) {
33
+ console . log ( "Failed to delete " + file ) ;
34
+ } ) ;
35
+ } ) ;
36
+ }
37
+
38
+ removeFiles ( "test/browser" , / t e s t - r u n n e r - [ a - z A - Z - ] * \. h t m $ / ) ;
25
39
createTestRunnerPage ( "" , / j a v a s c r i p t | u r l s / , "main" ) ;
26
40
createTestRunnerPage ( "" , null , "legacy" , "legacy" ) ;
27
41
createTestRunnerPage ( "" , / j a v a s c r i p t / , "errors" , "errors" ) ;
0 commit comments