Skip to content

Commit 47582ca

Browse files
authored
Convert to @scalvert/bin-tester (#333)
1 parent b26f5f3 commit 47582ca

File tree

5 files changed

+291
-224
lines changed

5 files changed

+291
-224
lines changed

.github/workflows/ci-build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
strategy:
1818
matrix:
1919
os: [ubuntu-latest]
20-
node: ['12']
20+
node: ['14']
2121

2222
steps:
2323
- uses: actions/checkout@v1

__tests__/__utils__/fake-project.ts

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ import {
55
TodoConfigByEngine,
66
} from '@lint-todo/utils';
77
import { dirname, join } from 'path';
8-
import fixturify from 'fixturify';
9-
import Project from 'fixturify-project';
108
import { mkdirpSync, symlinkSync } from 'fs-extra';
9+
import { BinTesterProject } from '@scalvert/bin-tester';
1110

1211
const DEFAULT_ESLINT_CONFIG = `{
1312
"env": {
@@ -69,58 +68,53 @@ const DEFAULT_ESLINT_CONFIG = `{
6968
}
7069
`;
7170

72-
export class FakeProject extends Project {
73-
static getInstance(): FakeProject {
71+
export class FakeProject extends BinTesterProject {
72+
static async getInstance(): Promise<FakeProject> {
7473
const project = new this();
7574

76-
// project.addDevDependency('eslint', '^7.10.0');
77-
7875
project.files['eslint-config.json'] = DEFAULT_ESLINT_CONFIG;
7976

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();
9278
// link binary
93-
this.symlink(
79+
project.symlink(
9480
join(__dirname, '../..', 'node_modules', '.bin', 'eslint'),
95-
join(this.baseDir, 'node_modules', '.bin', 'eslint')
81+
join(project.baseDir, 'node_modules', '.bin', 'eslint')
9682
);
9783

9884
// link package
99-
this.symlink(
85+
project.symlink(
10086
join(__dirname, '../..', 'node_modules', 'eslint'),
101-
join(this.baseDir, 'node_modules', 'eslint')
87+
join(project.baseDir, 'node_modules', 'eslint')
10288
);
89+
90+
return project;
10391
}
10492

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+
};
108102
}
109103

110-
setShorthandPackageJsonTodoConfig(daysToDecay: DaysToDecay): void {
104+
setShorthandPackageJsonTodoConfig(daysToDecay: DaysToDecay): Promise<void> {
111105
this.pkg = Object.assign({}, this.pkg, {
112106
lintTodo: {
113107
daysToDecay,
114108
},
115109
});
116110

117-
this.writeSync();
111+
return this.write();
118112
}
119113

120114
setPackageJsonTodoConfig(
121115
daysToDecay: DaysToDecay,
122116
daysToDecayByRule?: DaysToDecayByRule
123-
): void {
117+
): Promise<void> {
124118
const todoConfig: LintTodoPackageJson = {
125119
lintTodo: {
126120
eslint: {
@@ -136,13 +130,13 @@ export class FakeProject extends Project {
136130

137131
this.pkg = Object.assign({}, this.pkg, todoConfig);
138132

139-
this.writeSync();
133+
return this.write();
140134
}
141135

142136
setLintTodorc(
143137
daysToDecay: DaysToDecay,
144138
daysToDecayByRule?: DaysToDecayByRule
145-
): void {
139+
): Promise<void> {
146140
const todoConfig: TodoConfigByEngine = {
147141
eslint: {
148142
daysToDecay,
@@ -153,7 +147,7 @@ export class FakeProject extends Project {
153147
todoConfig['eslint'].daysToDecayByRule = daysToDecayByRule;
154148
}
155149

156-
this.write({
150+
return this.write({
157151
'.lint-todorc.js': `module.exports = ${JSON.stringify(
158152
todoConfig,
159153
// eslint-disable-next-line unicorn/no-null

0 commit comments

Comments
 (0)