5
5
TodoConfigByEngine ,
6
6
} from '@lint-todo/utils' ;
7
7
import { dirname , join } from 'path' ;
8
- import fixturify from 'fixturify' ;
9
- import Project from 'fixturify-project' ;
10
8
import { mkdirpSync , symlinkSync } from 'fs-extra' ;
9
+ import { BinTesterProject } from '@scalvert/bin-tester' ;
11
10
12
11
const DEFAULT_ESLINT_CONFIG = `{
13
12
"env": {
@@ -69,58 +68,53 @@ const DEFAULT_ESLINT_CONFIG = `{
69
68
}
70
69
` ;
71
70
72
- export class FakeProject extends Project {
73
- static getInstance ( ) : FakeProject {
71
+ export class FakeProject extends BinTesterProject {
72
+ static async getInstance ( ) : Promise < FakeProject > {
74
73
const project = new this ( ) ;
75
74
76
- // project.addDevDependency('eslint', '^7.10.0');
77
-
78
75
project . files [ 'eslint-config.json' ] = DEFAULT_ESLINT_CONFIG ;
79
76
80
- return project ;
81
- }
82
-
83
- constructor ( name = 'fake-project' , ...args : any [ ] ) {
84
- super ( name , ...args ) ;
85
-
86
- this . pkg = Object . assign ( { } , this . pkg , {
87
- license : 'MIT' ,
88
- description : 'Fake project' ,
89
- repository : 'http://fakerepo.com' ,
90
- } ) ;
91
-
77
+ await project . write ( ) ;
92
78
// link binary
93
- this . symlink (
79
+ project . symlink (
94
80
join ( __dirname , '../..' , 'node_modules' , '.bin' , 'eslint' ) ,
95
- join ( this . baseDir , 'node_modules' , '.bin' , 'eslint' )
81
+ join ( project . baseDir , 'node_modules' , '.bin' , 'eslint' )
96
82
) ;
97
83
98
84
// link package
99
- this . symlink (
85
+ project . symlink (
100
86
join ( __dirname , '../..' , 'node_modules' , 'eslint' ) ,
101
- join ( this . baseDir , 'node_modules' , 'eslint' )
87
+ join ( project . baseDir , 'node_modules' , 'eslint' )
102
88
) ;
89
+
90
+ return project ;
103
91
}
104
92
105
- write ( dirJSON : fixturify . DirJSON ) : void {
106
- Object . assign ( this . files , dirJSON ) ;
107
- this . writeSync ( ) ;
93
+ constructor ( name = 'fake-project' , ...args : any [ ] ) {
94
+ super ( name , ...args ) ;
95
+
96
+ this . pkg = {
97
+ ...this . pkg ,
98
+ license : 'MIT' ,
99
+ description : 'Fake project' ,
100
+ repository : 'http://fakerepo.com' ,
101
+ } ;
108
102
}
109
103
110
- setShorthandPackageJsonTodoConfig ( daysToDecay : DaysToDecay ) : void {
104
+ setShorthandPackageJsonTodoConfig ( daysToDecay : DaysToDecay ) : Promise < void > {
111
105
this . pkg = Object . assign ( { } , this . pkg , {
112
106
lintTodo : {
113
107
daysToDecay,
114
108
} ,
115
109
} ) ;
116
110
117
- this . writeSync ( ) ;
111
+ return this . write ( ) ;
118
112
}
119
113
120
114
setPackageJsonTodoConfig (
121
115
daysToDecay : DaysToDecay ,
122
116
daysToDecayByRule ?: DaysToDecayByRule
123
- ) : void {
117
+ ) : Promise < void > {
124
118
const todoConfig : LintTodoPackageJson = {
125
119
lintTodo : {
126
120
eslint : {
@@ -136,13 +130,13 @@ export class FakeProject extends Project {
136
130
137
131
this . pkg = Object . assign ( { } , this . pkg , todoConfig ) ;
138
132
139
- this . writeSync ( ) ;
133
+ return this . write ( ) ;
140
134
}
141
135
142
136
setLintTodorc (
143
137
daysToDecay : DaysToDecay ,
144
138
daysToDecayByRule ?: DaysToDecayByRule
145
- ) : void {
139
+ ) : Promise < void > {
146
140
const todoConfig : TodoConfigByEngine = {
147
141
eslint : {
148
142
daysToDecay,
@@ -153,7 +147,7 @@ export class FakeProject extends Project {
153
147
todoConfig [ 'eslint' ] . daysToDecayByRule = daysToDecayByRule ;
154
148
}
155
149
156
- this . write ( {
150
+ return this . write ( {
157
151
'.lint-todorc.js' : `module.exports = ${ JSON . stringify (
158
152
todoConfig ,
159
153
// eslint-disable-next-line unicorn/no-null
0 commit comments