37 lines
685 B
JavaScript
37 lines
685 B
JavaScript
#!/usr/bin/env node
|
|
|
|
/**
|
|
* Wrapper script to fix Next.js lint command bug
|
|
* that interprets "lint" as a directory instead of a command
|
|
*/
|
|
|
|
const { execSync } = require('child_process')
|
|
|
|
const projectRoot = process.cwd()
|
|
|
|
function runEslint() {
|
|
execSync('npx eslint . --ext .ts,.tsx --ignore-pattern next-env.d.ts', {
|
|
stdio: 'inherit',
|
|
cwd: projectRoot,
|
|
})
|
|
}
|
|
|
|
function runNextLint() {
|
|
process.chdir(projectRoot)
|
|
execSync('npx next lint', {
|
|
stdio: 'inherit',
|
|
cwd: projectRoot,
|
|
env: { ...process.env, PWD: projectRoot },
|
|
})
|
|
}
|
|
|
|
try {
|
|
if (process.env.USE_NEXT_LINT === '1') {
|
|
runNextLint()
|
|
} else {
|
|
runEslint()
|
|
}
|
|
} catch {
|
|
process.exit(1)
|
|
}
|