2
2
3
3
var expect = require ( 'expect' ) ;
4
4
5
+ var os = require ( 'os' ) ;
5
6
var fs = require ( 'fs' ) ;
6
7
var path = require ( 'path' ) ;
7
8
var vinyl = require ( 'vinyl-fs' ) ;
@@ -14,6 +15,15 @@ var through = require('through2');
14
15
15
16
var Undertaker = require ( '../' ) ;
16
17
18
+ var isWindows = ( os . platform ( ) === 'win32' ) ;
19
+
20
+ function cleanup ( ) {
21
+ return del ( [
22
+ path . join ( __dirname , './fixtures/out/' ) ,
23
+ path . join ( __dirname , './fixtures/tmp/' ) ,
24
+ ] ) ;
25
+ }
26
+
17
27
describe ( 'integrations' , function ( ) {
18
28
19
29
var taker ;
@@ -23,6 +33,9 @@ describe('integrations', function() {
23
33
done ( ) ;
24
34
} ) ;
25
35
36
+ beforeEach ( cleanup ) ;
37
+ afterEach ( cleanup ) ;
38
+
26
39
it ( 'should handle vinyl streams' , function ( done ) {
27
40
taker . task ( 'test' , function ( ) {
28
41
return vinyl . src ( './fixtures/test.js' , { cwd : __dirname } )
@@ -51,6 +64,10 @@ describe('integrations', function() {
51
64
52
65
it ( 'should handle a child process return' , function ( done ) {
53
66
taker . task ( 'test' , function ( ) {
67
+ if ( isWindows ) {
68
+ return spawn ( 'cmd' , [ '/c' , 'dir' ] ) . on ( 'error' , console . log ) ;
69
+ }
70
+
54
71
return spawn ( 'ls' , [ '-lh' , __dirname ] ) ;
55
72
} ) ;
56
73
@@ -109,30 +126,27 @@ describe('integrations', function() {
109
126
} ) ;
110
127
111
128
it ( 'can use lastRun with vinyl.src `since` option' , function ( done ) {
129
+ this . timeout ( 5000 ) ;
130
+
112
131
var count = 0 ;
113
- var filepath = path . join ( __dirname , './fixtures/tmp/testMore.js' ) ;
114
132
115
133
function setup ( ) {
116
134
return vinyl . src ( './fixtures/test*.js' , { cwd : __dirname } )
117
135
. pipe ( vinyl . dest ( './fixtures/tmp' , { cwd : __dirname } ) ) ;
118
136
}
119
137
138
+ function delay ( cb ) {
139
+ setTimeout ( cb , 2000 ) ;
140
+ }
141
+
120
142
// Some built
121
143
taker . task ( 'build' , function ( ) {
122
144
return vinyl . src ( './fixtures/tmp/*.js' , { cwd : __dirname } )
123
145
. pipe ( vinyl . dest ( './fixtures/out' , { cwd : __dirname } ) ) ;
124
146
} ) ;
125
147
126
- function userWait ( cd ) {
127
- setTimeout ( cd , 1100 ) ;
128
- }
129
-
130
148
function userEdit ( cb ) {
131
- fs . appendFile ( filepath , ' ' , cb ) ;
132
- }
133
-
134
- function cleanup ( cb ) {
135
- fs . unlink ( filepath , cb ) ;
149
+ fs . appendFile ( path . join ( __dirname , './fixtures/tmp/testMore.js' ) , ' ' , cb ) ;
136
150
}
137
151
138
152
function countEditedFiles ( ) {
@@ -143,9 +157,9 @@ describe('integrations', function() {
143
157
} ) ) ;
144
158
}
145
159
146
- taker . series ( setup , 'build' , userWait , userEdit , countEditedFiles , cleanup , function ( cb ) {
160
+ taker . series ( setup , delay , 'build' , delay , userEdit , countEditedFiles ) ( function ( err ) {
147
161
expect ( count ) . toEqual ( 1 ) ;
148
- cb ( ) ;
149
- } ) ( done ) ;
162
+ done ( err ) ;
163
+ } ) ;
150
164
} ) ;
151
165
} ) ;
0 commit comments