@@ -23,17 +23,19 @@ const log = logger.child({ module: 'collect/source' });
2323/**
2424 * Inspects important files, such as the tests and README file sizes.
2525 *
26- * @param {object } data The package data
27- * @param {string } dir The package directory
26+ * @param {object } data The package data
27+ * @param {string } dir The package directory
28+ * @param {object } packageJson The latest package.json data (normalized)
2829 *
2930 * @return {Promise } The promise for the inspection result
3031 */
31- function inspectFiles ( data , dir ) {
32+ function inspectFiles ( data , dir , packageJson ) {
3233 return Promise . props ( {
3334 readmeSize : data . readmeFilename ? fileSize ( `${ dir } /${ data . readmeFilename } ` ) : 0 ,
3435 testsSize : detectRepoTestFiles ( dir ) . then ( ( files ) => fileSize ( files ) ) ,
3536 hasNpmIgnore : isRegularFile ( `${ dir } /.npmignore` ) . then ( ( is ) => is || null ) ,
3637 hasShrinkwrap : isRegularFile ( `${ dir } /npm-shrinkwrap.json` ) . then ( ( is ) => is || null ) ,
38+ hasTypeScriptDeclaration : isRegularFile ( path . join ( dir , String ( packageJson . typings || packageJson . types || 'index.d.ts' ) ) ) . then ( ( is ) => is || null ) ,
3739 hasChangelog : detectRepoChangelog ( dir ) . then ( ( file ) => ! ! file ) . then ( ( is ) => is || null ) ,
3840 } ) ;
3941}
@@ -183,7 +185,7 @@ function source(data, packageJson, downloaded, options) {
183185
184186 // Analyze source first because the external tools add files to the directory
185187 return promisePropsSettled ( {
186- files : inspectFiles ( data , downloaded . dir ) ,
188+ files : inspectFiles ( data , downloaded . dir , packageJson ) ,
187189 repositorySize : fileSize . dir ( downloaded . dir ) ,
188190 linters : detectRepoLinters ( downloaded . dir ) ,
189191 coverage : fetchCodeCoverage ( packageJson , badges ) ,
0 commit comments