Skip to content

Commit

Permalink
Add flag for TypeScript modules
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Apr 3, 2017
1 parent 79279de commit 40d1027
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions config/elasticsearch/npms.json5
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@
"deprecated": { "type": "string", "index": "not_analyzed" },
"insecure": { "type": "integer" },
"unstable": { "type": "boolean" },
"dts": { "type": "boolean" },
},
},
"evaluation": {
Expand Down
10 changes: 6 additions & 4 deletions lib/analyze/collect/source.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ const log = logger.child({ module: 'collect/source' });
/**
* Inspects important files, such as the tests and README file sizes.
*
* @param {object} data The package data
* @param {string} dir The package directory
* @param {object} data The package data
* @param {string} dir The package directory
* @param {object} packageJson The latest package.json data (normalized)
*
* @return {Promise} The promise for the inspection result
*/
function inspectFiles(data, dir) {
function inspectFiles(data, dir, packageJson) {
return Promise.props({
readmeSize: data.readmeFilename ? fileSize(`${dir}/${data.readmeFilename}`) : 0,
testsSize: detectRepoTestFiles(dir).then((files) => fileSize(files)),
hasNpmIgnore: isRegularFile(`${dir}/.npmignore`).then((is) => is || null),
hasShrinkwrap: isRegularFile(`${dir}/npm-shrinkwrap.json`).then((is) => is || null),
hasTypeScriptDeclaration: isRegularFile(path.join(dir, String(packageJson.typings || packageJson.types || 'index.d.ts'))).then((is) => is || null),
hasChangelog: detectRepoChangelog(dir).then((file) => !!file).then((is) => is || null),
});
}
Expand Down Expand Up @@ -183,7 +185,7 @@ function source(data, packageJson, downloaded, options) {

// Analyze source first because the external tools add files to the directory
return promisePropsSettled({
files: inspectFiles(data, downloaded.dir),
files: inspectFiles(data, downloaded.dir, packageJson),
repositorySize: fileSize.dir(downloaded.dir),
linters: detectRepoLinters(downloaded.dir),
coverage: fetchCodeCoverage(packageJson, badges),
Expand Down
1 change: 1 addition & 0 deletions lib/scoring/score.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ function buildScore(analysis, aggregation) {
deprecated: collected.metadata.deprecated,
insecure: collected.source && collected.source.vulnerabilities ? collected.source.vulnerabilities.length : null,
unstable: semver.lt(collected.metadata.version, '1.0.0', true) ? true : null,
dts: collected.source && collected.source.hasTypeScriptDeclaration,
},
evaluation,
score: {
Expand Down

0 comments on commit 40d1027

Please sign in to comment.