lerna-script-tasks-depcheck
Advanced tools
Comparing version 1.1.2 to 1.2.0
29
index.js
@@ -1,3 +0,4 @@ | ||
const {loadPackages, iter} = require('lerna-script'), | ||
checkDeps = require('depcheck') | ||
const {loadPackages, iter} = require('lerna-script') | ||
const checkDeps = require('depcheck') | ||
const colors = require('colors') | ||
@@ -9,4 +10,4 @@ function depcheckTask({packages, depcheck} = {}) { | ||
return iter.parallel(lernaPackages, {build: 'depcheck', log})((lernaPackage, log) => { | ||
return checkModule(lernaPackage, log, depcheck) | ||
return iter.parallel(lernaPackages, {build: 'depcheck'})(lernaPackage => { | ||
return checkModule(lernaPackage, depcheck) | ||
}) | ||
@@ -16,16 +17,18 @@ } | ||
function checkModule(lernaPackage, log, depcheckOpts = {}) { | ||
function checkModule(lernaPackage, depcheckOpts = {}) { | ||
return Promise.resolve() | ||
.then(() => checkDeps(lernaPackage.location, depcheckOpts, val => val)) | ||
.then(({dependencies, devDependencies}) => { | ||
const unusedDeps = devDependencies.concat(dependencies) | ||
if (unusedDeps.length > 0) { | ||
log.error( | ||
'depcheck', | ||
`module ${lernaPackage.name} has unused dependencies: ${unusedDeps.join(', ')}` | ||
) | ||
const hasUnusedDeps = devDependencies.concat(dependencies).length > 0 | ||
if (hasUnusedDeps) { | ||
console.log(`\nunused deps found for module ${colors.brightCyan.bold(lernaPackage.name)}`) | ||
if (dependencies.length > 0) { | ||
console.log({dependencies}) | ||
} | ||
if (devDependencies.length > 0) { | ||
console.log({devDependencies}) | ||
} | ||
return Promise.reject(new Error(`unused deps found for module ${lernaPackage.name}`)) | ||
} else { | ||
return Promise.resolve() | ||
} | ||
return Promise.resolve() | ||
}) | ||
@@ -32,0 +35,0 @@ } |
{ | ||
"name": "lerna-script-tasks-depcheck", | ||
"version": "1.1.2", | ||
"version": "1.2.0", | ||
"description": "tasks for running depcheck for all modules", | ||
@@ -20,3 +20,4 @@ "author": "Vilius Lukosius", | ||
"dependencies": { | ||
"depcheck": "0.9.1" | ||
"colors": "1.4.0", | ||
"depcheck": "0.9.2" | ||
}, | ||
@@ -30,9 +31,9 @@ "peerDependencies": { | ||
"lerna": "3.20.2", | ||
"lerna-script": "^1.1.2", | ||
"lerna-script-test-utils": "^1.1.2", | ||
"mocha": "7.0.0", | ||
"sinon": "8.1.0", | ||
"lerna-script": "^1.2.0", | ||
"lerna-script-test-utils": "^1.2.0", | ||
"mocha": "7.0.1", | ||
"sinon": "8.1.1", | ||
"sinon-chai": "3.4.0" | ||
}, | ||
"gitHead": "dc2b97aafc14cb03bfff30be03aa183a807502c7" | ||
"gitHead": "0f3500d89d6fe9e2896cfc305fdd0fce79d2be45" | ||
} |
@@ -5,3 +5,5 @@ const {aLernaProject, loggerMock} = require('lerna-script-test-utils'), | ||
depcheckTask = require('..'), | ||
invertPromise = require('invert-promise') | ||
invertPromise = require('invert-promise'), | ||
sinon = require('sinon'), | ||
colors = require('colors') | ||
@@ -11,2 +13,3 @@ describe('depcheck', () => { | ||
const log = loggerMock() | ||
console.log = sinon.spy() | ||
const project = await aLernaProject({a: ['lodash']}) | ||
@@ -23,7 +26,7 @@ | ||
).then(err => { | ||
expect(log.item.error).to.have.been.calledWith( | ||
'depcheck', | ||
'module a has unused dependencies: lodash' | ||
expect(err.message).to.be.string('unused deps found for module a') | ||
expect(console.log.firstCall).to.have.been.calledWith( | ||
`\nunused deps found for module ${colors.brightCyan.bold('a')}` | ||
) | ||
expect(err.message).to.be.string('unused deps found for module a') | ||
expect(console.log).to.have.been.calledWithMatch({dependencies: ['lodash']}) | ||
}) | ||
@@ -30,0 +33,0 @@ }) |
5960
95
3
+ Addedcolors@1.4.0
+ Addedcolors@1.4.0(transitive)
+ Addeddepcheck@0.9.2(transitive)
- Removedansi-regex@4.1.1(transitive)
- Removedcliui@5.0.0(transitive)
- Removeddepcheck@0.9.1(transitive)
- Removedemoji-regex@7.0.3(transitive)
- Removedfind-up@3.0.0(transitive)
- Removedis-fullwidth-code-point@2.0.0(transitive)
- Removedlocate-path@3.0.0(transitive)
- Removedp-locate@3.0.0(transitive)
- Removedpath-exists@3.0.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedstring-width@3.1.0(transitive)
- Removedstrip-ansi@5.2.0(transitive)
- Removedwrap-ansi@5.1.0(transitive)
- Removedyargs@14.2.3(transitive)
- Removedyargs-parser@15.0.3(transitive)
Updateddepcheck@0.9.2