Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly detect JS projects with type checking #20944

Merged
merged 4 commits into from
Feb 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions code/lib/cli/src/detect.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import path from 'path';
import fs from 'fs';
import findUp from 'find-up';
import semver from 'semver';
Expand Down Expand Up @@ -85,7 +84,7 @@ const getFrameworkPreset = (
}

if (Array.isArray(files) && files.length > 0) {
matcher.files = files.map((name) => fs.existsSync(path.join(process.cwd(), name)));
matcher.files = files.map((name) => fs.existsSync(name));
}

return matcherFunction(matcher) ? preset : null;
Expand Down Expand Up @@ -151,7 +150,9 @@ export function isStorybookInstalled(
export function detectLanguage(packageJson?: PackageJson) {
let language = SupportedLanguage.JAVASCRIPT;

if (!packageJson) {
// TODO: we may need to also detect whether a jsconfig.json file is present
// in a monorepo root directory
if (!packageJson || fs.existsSync('jsconfig.json')) {
return language;
}

Expand Down