File tree 3 files changed +8
-9
lines changed
3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ export type Detection = {
33
33
accuracy : Accuracy
34
34
/** The NPM package that was able to detect it (high accuracy) */
35
35
package ?: { name : string ; version ?: SemVer }
36
- packageJSON ?: PackageJson
36
+ packageJSON ?: Partial < PackageJson >
37
37
/** The absolute path to config file that is associated with the framework */
38
38
config ?: string
39
39
/** The name of config file that is associated with the framework */
@@ -246,7 +246,9 @@ export abstract class BaseFramework implements Framework {
246
246
}
247
247
248
248
/** check if the npmDependencies are used inside the provided package.json */
249
- private async npmDependenciesUsed ( pkgJSON : PackageJson ) : Promise < { name : string ; version ?: SemVer } | undefined > {
249
+ private async npmDependenciesUsed (
250
+ pkgJSON : Partial < PackageJson > ,
251
+ ) : Promise < { name : string ; version ?: SemVer } | undefined > {
250
252
const allDeps = [ ...Object . entries ( pkgJSON . dependencies || { } ) , ...Object . entries ( pkgJSON . devDependencies || { } ) ]
251
253
252
254
const found = allDeps . find ( ( [ depName ] ) => this . npmDependencies . includes ( depName ) )
Original file line number Diff line number Diff line change @@ -172,7 +172,7 @@ export class Project {
172
172
}
173
173
174
174
/** retrieves the root package.json file */
175
- async getRootPackageJSON ( ) : Promise < PackageJson > {
175
+ async getRootPackageJSON ( ) : Promise < Partial < PackageJson > > {
176
176
// get the most upper json file
177
177
const rootJSONPath = (
178
178
await this . fs . findUpMultiple ( 'package.json' , { cwd : this . baseDirectory , stopAt : this . root } )
@@ -185,17 +185,14 @@ export class Project {
185
185
}
186
186
187
187
/** Retrieves the package.json and if one found with it's pkgPath */
188
- async getPackageJSON ( startDirectory ?: string ) : Promise < PackageJson & { pkgPath : string | null } > {
188
+ async getPackageJSON ( startDirectory ?: string ) : Promise < Partial < PackageJson > & { pkgPath : string | null } > {
189
189
const pkgPath = await this . fs . findUp ( 'package.json' , {
190
190
cwd : startDirectory || this . baseDirectory ,
191
191
stopAt : this . root ,
192
192
} )
193
193
if ( pkgPath ) {
194
194
const json = await this . fs . readJSON < PackageJson > ( pkgPath )
195
- return {
196
- ...json ,
197
- pkgPath,
198
- }
195
+ return Object . assign ( json , { pkgPath } )
199
196
}
200
197
return { pkgPath : null }
201
198
}
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ export async function detectPnpmWorkspaceGlobs(project: Project): Promise<string
54
54
}
55
55
56
56
/** Get the workspace globs from the package.json file */
57
- export async function detectNpmOrYarnWorkspaceGlobs ( pkgJSON : PackageJson ) : Promise < string [ ] > {
57
+ export async function detectNpmOrYarnWorkspaceGlobs ( pkgJSON : Partial < PackageJson > ) : Promise < string [ ] > {
58
58
if ( Array . isArray ( pkgJSON . workspaces ) ) {
59
59
return pkgJSON . workspaces || [ ]
60
60
}
You can’t perform that action at this time.
0 commit comments