33const fs = require ( 'node:fs/promises' ) ;
44const path = require ( 'node:path' ) ;
55const assert = require ( 'node:assert' ) ;
6+ const os = require ( 'node:os' ) ;
67const coffee = require ( 'coffee' ) ;
78const semver = require ( 'semver' ) ;
89const execa = require ( 'execa' ) ;
@@ -20,16 +21,25 @@ describe('test/index.v2.test.js', () => {
2021 let cwd ;
2122
2223 afterEach ( async ( ) => {
23- await clean ( { cwd } ) ;
24+ try {
25+ await clean ( { cwd, daemon : true } ) ;
26+ } catch ( e ) {
27+ console . warn ( 'clean error: ' , e ) ;
28+ }
2429 if ( process . platform === 'darwin' ) {
2530 try {
2631 await forceExitDaemon ( ) ;
2732 } catch ( err ) {
2833 console . warn ( 'force exit daemon error: %s' , err . message ) ;
2934 }
3035 } else {
31- await exitDaemon ( ) ;
36+ try {
37+ await exitDaemon ( ) ;
38+ } catch ( err ) {
39+ console . warn ( 'exit daemon error: %s' , err . message ) ;
40+ }
3241 }
42+
3343 } ) ;
3444
3545 describe ( 'update' , ( ) => {
@@ -125,8 +135,10 @@ describe('test/index.v2.test.js', () => {
125135 . end ( ) ;
126136
127137 await assert . doesNotReject ( fs . stat ( path . join ( cwd , 'node_modules/react-jsx-parser/package.json' ) ) ) ;
128- const { stdout } = await execa . command ( 'mount' , { stdio : 'pipe' } ) ;
129- assert ( stdout . indexOf ( cwd ) > 0 ) ;
138+ if ( os . type ( ) === 'Darwin' ) {
139+ const { stdout } = await execa . command ( 'mount' , { stdio : 'pipe' } ) ;
140+ assert ( stdout . indexOf ( cwd ) > 0 ) ;
141+ }
130142 assert ( require ( path . join ( cwd , 'node_modules/react-jsx-parser/package.json' ) ) . version === '1.29.0' ) ;
131143 } ) ;
132144
@@ -205,7 +217,7 @@ describe('test/index.v2.test.js', () => {
205217 } ) ;
206218
207219
208- describe ( 'deamon' , async ( ) => {
220+ describe . only ( 'deamon' , async ( ) => {
209221 it ( 'should work' , async ( ) => {
210222 cwd = path . join ( __dirname , './fixtures/esbuild' ) ;
211223 await coffee
@@ -223,9 +235,8 @@ describe('test/index.v2.test.js', () => {
223235 assert . strictEqual ( dirs . filter ( dir => dir . includes ( 'esbuild' ) ) . length , 2 ) ;
224236 await assert . doesNotReject ( fs . stat ( path . join ( cwd , 'node_modules/esbuild' ) ) ) ;
225237 assert . strictEqual ( require ( path . join ( cwd , 'node_modules' , 'esbuild/package.json' ) ) . version , '0.15.14' ) ;
226- const nodeModulesDir = path . join ( cwd , 'node_modules' ) ;
227238
228- await execa . command ( `umount -f ${ nodeModulesDir } ` ) ;
239+ await execa . command ( 'killall -9 nydusd' ) ;
229240 await setTimeoutPromise ( 20000 ) ;
230241 assert . strictEqual ( require ( path . join ( cwd , 'node_modules' , 'esbuild/package.json' ) ) . version , '0.15.14' ) ;
231242 } ) ;
@@ -248,9 +259,8 @@ describe('test/index.v2.test.js', () => {
248259 assert . strictEqual ( dirs . filter ( dir => dir . includes ( 'esbuild' ) ) . length , 2 ) ;
249260 await assert . doesNotReject ( fs . stat ( path . join ( cwd , 'node_modules/esbuild' ) ) ) ;
250261 assert . strictEqual ( require ( path . join ( cwd , 'node_modules' , 'esbuild/package.json' ) ) . version , '0.15.14' ) ;
251- const nodeModulesDir = path . join ( cwd , 'node_modules' ) ;
252262
253- await execa . command ( `umount -f ${ nodeModulesDir } ` ) ;
263+ await execa . command ( 'killall -9 nydusd' ) ;
254264 await setTimeoutPromise ( 20000 ) ;
255265
256266 await assert . rejects ( fs . stat ( path . join ( cwd , 'node_modules' , 'esbuild/package.json' ) ) ) ;
0 commit comments