nextdevkit
Version:
A Comprehensive CLI Toolkit for Next.js Development
23 lines (22 loc) • 759 B
JavaScript
import fs from 'fs-extra';
import path from 'path';
const isNextJsRoot = async (directory) => {
try {
const packageJsonPath = path.join(directory, 'package.json');
const nextConfigFiles = [
'next.config.js',
'next.config.mjs',
'next.config.ts'
];
const [packageJsonExists, ...nextConfigExists] = await Promise.all([
fs.pathExists(packageJsonPath),
...nextConfigFiles.map((file) => fs.pathExists(path.join(directory, file)))
]);
return packageJsonExists && nextConfigExists.some((exists) => exists);
}
catch (error) {
console.error('Error checking Next.js root:', error);
return false;
}
};
export default isNextJsRoot;