@@ -25,6 +25,7 @@ import path from 'path'
25
25
import log from '../util/log'
26
26
import { getPackage } from '../npm/package'
27
27
import outdent from 'outdent'
28
+ import { fileExists , mkdir } from '../util/files'
28
29
29
30
interface YalcWatchConfig {
30
31
folder ?: string
@@ -38,7 +39,7 @@ interface PackageJson {
38
39
39
40
export async function linkWatch ( { basePath} : { basePath : string } ) {
40
41
const packageJson : PackageJson = JSON . parse (
41
- fs . readFileSync ( path . join ( process . cwd ( ) , 'package.json' ) , 'utf8' )
42
+ fs . readFileSync ( path . join ( basePath , 'package.json' ) , 'utf8' )
42
43
)
43
44
44
45
const watch : Required < YalcWatchConfig > = {
@@ -55,8 +56,16 @@ export async function linkWatch({basePath}: {basePath: string}) {
55
56
//delay: 1000
56
57
} )
57
58
59
+ // ensure the folder exits so it can be watched
60
+ const folder = path . join ( basePath , watch . folder )
61
+ if ( ! ( await fileExists ( folder ) ) ) {
62
+ await mkdir ( folder )
63
+ }
64
+
58
65
const pkg = await getPackage ( { basePath, validate : false } )
59
66
67
+ concurrently ( [ watch . command ] )
68
+
60
69
nodemon
61
70
. on ( 'start' , function ( ) {
62
71
log . info (
@@ -75,6 +84,4 @@ export async function linkWatch({basePath}: {basePath: string}) {
75
84
log . info ( 'Found changes in files:' , chalk . magentaBright ( files ) )
76
85
log . info ( 'Pushing new yalc package...' )
77
86
} )
78
-
79
- concurrently ( [ watch . command ] )
80
87
}
0 commit comments