New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lerna-script-tasks-depcheck

Package Overview
Dependencies
Maintainers
3
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lerna-script-tasks-depcheck - npm Package Compare versions

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 @@ })

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc