Skip to content

Commit 18e799c

Browse files
author
linfeng
committed
fix: npx
1 parent d6f8261 commit 18e799c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/utils/lint.ts

+4-6
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@ export async function lint(options?: Partial<DefaultOptions>) {
7474
const lintResult = await spinner(
7575
`Lint ${mergedOptions.lintAll ? 'all' : ''} ${lintFiles.length} files.`,
7676
async () => {
77-
const files = execSync(
78-
`${globalState.projectRootPath}/node_modules/.bin/prettier --list-different --write ${lintFiles.join(' ')}`,
79-
);
77+
const files = execSync(`npx prettier --list-different --write ${lintFiles.join(' ')}`);
8078
prettierFiles = _.compact(files.toString().split('\n'));
8179
return cli.executeOnFiles(lintFiles);
8280
},
@@ -156,16 +154,16 @@ export async function lint(options?: Partial<DefaultOptions>) {
156154
}
157155

158156
if (mergedOptions.needFix && (lintResult.results.some(each => each.output) || prettierFiles.length > 0)) {
159-
const fixedFiles = _.uniq(
157+
const fixedFilePaths = _.uniq(
160158
lintResult.results
161159
.filter(each => each.output)
162160
.map(item => item.filePath)
163161
.concat(prettierFiles),
164162
);
165163

166164
// eslint-disable-next-line no-console
167-
console.log(colors.yellow(`${fixedFiles.length} files autofixed, please recheck your code.`));
168-
execSync(`git add ${fixedFiles.join(' ')}`);
165+
console.log(colors.yellow(`${fixedFilePaths.length} files autofixed, please recheck your code.`));
166+
execSync(`git add ${fixedFilePaths.join(' ')}`);
169167
}
170168

171169
if (mergedOptions.typeCheck) {

0 commit comments

Comments
 (0)