Skip to content

Commit

Permalink
Optional next.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdaniels committed Aug 29, 2022
1 parent a1eb7c9 commit 066b6c8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/frameworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const dynamicImport = async (getProjectPath: PathFactory) => {
const packageJsonBuffer = await readFile(getProjectPath('package.json'));
const packageJson = JSON.parse(packageJsonBuffer.toString());
if (packageJson.directories?.serve) return import('./express/index.js');
if (fileExists('next.config.js')) return import('./next.js/index.js');
if (fileExists('next.config.js') || findDependency('next', getProjectPath(), 0)) return import('./next.js/index.js');
if (fileExists('nuxt.config.js', 'nuxt.config.ts')) return import('./nuxt/index.js');
if (fileExists('angular.json')) return import('./angular/index.js');
throw UNKNOWN_FRAMEWORK;
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export type DeployConfig = {

export type PathFactory = (...args: string[]) => string;

export const findDependency = (name: string, cwd=process.cwd()) => {
const result = spawnSync(Commands.NPM, ['list', name, '--json', '--omit', 'dev'], { cwd });
export const findDependency = (name: string, cwd=process.cwd(), depth?: number) => {
const result = spawnSync(Commands.NPM, ['list', name, '--json', '--omit', 'dev', ...(depth === undefined ? [] : ['--depth', depth.toString(10)])], { cwd });
if (!result.stdout) return undefined;
const json = JSON.parse(result.stdout.toString());
const search = (searchingFor: string, dependencies={}): any => {
Expand Down

0 comments on commit 066b6c8

Please sign in to comment.