11/**
22 * Test dependencies
33 */
4- const exec = require ( "child_process" ) . exec
5- const spawn = require ( "child_process" ) . spawn
6- const fs = require ( "fs" )
4+ import { exec , spawn } from "child_process"
5+ import fs from "fs"
76
8- const test = require ( "tape" )
7+ import test from "tape"
98
10- const utils = require ( "./utils" )
9+ import utils from "./utils"
10+
11+ import isBabel from "./utils/isBabel"
1112
1213// I don't success to call the kill() process from node and both Travis CI and
1314// Appveyor so we avoid this test on this environnements
1415if ( ! ( process . env . TRAVIS || process . env . APPVEYOR ) ) {
1516 // node bin is used to help for windows
16- const cssnextBin = "node dist/bin"
17+ const nodeBin = isBabel ? "babel-node" : "node"
18+ const cssnextBin = isBabel ? "src/bin" : "dist/bin"
1719
1820 test ( "cli/watcher" , function ( t ) {
1921 let planned = 0
2022
2123 const watchProcess = exec (
22- cssnextBin +
24+ ` ${ nodeBin } ${ cssnextBin } ` +
2325 " --watch src/__tests__/fixtures/cli.error.css" +
2426 " src/__tests__/fixtures/cli.output--watch.css" ,
2527 function ( err ) {
@@ -51,9 +53,10 @@ if (!(process.env.TRAVIS || process.env.APPVEYOR)) {
5153 const watchOut = "src/__tests__/fixtures/cli.output--watch-import.css"
5254
5355 const watchImportProcess = spawn (
54- "node" ,
56+ nodeBin ,
5557 [
56- "dist/bin" ,
58+ cssnextBin ,
59+ // "--verbose",
5760 "--watch" ,
5861 "src/__tests__/fixtures/cli.watch-import.css" ,
5962 watchOut ,
@@ -69,7 +72,9 @@ if (!(process.env.TRAVIS || process.env.APPVEYOR)) {
6972 // cli.import2.css
7073 fs . writeFileSync (
7174 "src/__tests__/fixtures/cli.watch-import.css" ,
72- "/**/ @import 'cli.watch-import-import.css';"
75+ "/**/ " +
76+ "@import 'cli.watch-import-import.css';" +
77+ "@import 'cli.watch-import-import2.css';"
7378 )
7479
7580 // we are using setTimeout for the watcher to do his job
@@ -80,7 +85,7 @@ if (!(process.env.TRAVIS || process.env.APPVEYOR)) {
8085 watchOut ,
8186 { encoding : "utf8" }
8287 ) ,
83- "/**/ watch{}" ,
88+ "/**/ watch{}er{} " ,
8489 "should update the file"
8590 )
8691
0 commit comments