@@ -132,12 +132,15 @@ function define (t) {
132
132
test ( '--standardlint option will add standard lint dependencies and scripts to javascript template' , async ( t ) => {
133
133
t . plan ( 14 + 3 )
134
134
try {
135
- rimraf . sync ( workdir )
136
- await pExec ( 'node ../generate workdir --standardlint' , { cwd : path . join ( workdir , '..' ) } )
135
+ const dir = path . join ( __dirname , 'workdir-with-lint' )
136
+ const cwd = path . join ( dir , '..' )
137
+ const bin = path . join ( '..' , 'generate' )
138
+ rimraf . sync ( dir )
139
+ await pExec ( `node ${ bin } ${ dir } --standardlint` , { cwd } )
137
140
138
- await verifyPkg ( t )
141
+ await verifyPkg ( t , dir , 'workdir-with-lint' )
139
142
140
- const data = await fsPromises . readFile ( path . join ( workdir , 'package.json' ) )
143
+ const data = await fsPromises . readFile ( path . join ( dir , 'package.json' ) )
141
144
const pkg = JSON . parse ( data )
142
145
t . equal ( pkg . scripts . pretest , 'standard' )
143
146
t . equal ( pkg . scripts . lint , 'standard --fix' )
@@ -147,14 +150,14 @@ function define (t) {
147
150
}
148
151
} )
149
152
150
- function verifyPkg ( t ) {
153
+ function verifyPkg ( t , dir = workdir , pkgName = 'workdir' ) {
151
154
return new Promise ( ( resolve , reject ) => {
152
- const pkgFile = path . join ( workdir , 'package.json' )
155
+ const pkgFile = path . join ( dir , 'package.json' )
153
156
154
157
readFile ( pkgFile , function ( err , data ) {
155
158
err && reject ( err )
156
159
const pkg = JSON . parse ( data )
157
- t . equal ( pkg . name , 'workdir' )
160
+ t . equal ( pkg . name , pkgName )
158
161
// we are not checking author because it depends on global npm configs
159
162
t . equal ( pkg . version , '1.0.0' )
160
163
t . equal ( pkg . description , 'This project was bootstrapped with Fastify-CLI.' )
0 commit comments