Socket
Socket
Sign inDemoInstall

dint

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dint - npm Package Compare versions

Comparing version 3.0.2 to 4.0.0

71

index.js

@@ -17,28 +17,25 @@ 'use strict'

function _retrieveFileIntegrities (rootDir, currDir, index) {
return fs.readdir(currDir)
.then((files) => {
return Promise.all(files.map((file) => {
async function _retrieveFileIntegrities (rootDir, currDir, index) {
try {
const files = await fs.readdir(currDir)
await Promise.all(files.map(async (file) => {
const fullPath = path.join(currDir, file)
return fs.stat(fullPath)
.then((stat) => {
if (stat.isDirectory()) {
return _retrieveFileIntegrities(rootDir, fullPath, index)
const stat = await fs.stat(fullPath)
if (stat.isDirectory()) {
return _retrieveFileIntegrities(rootDir, fullPath, index)
}
if (stat.isFile()) {
const relativePath = path.relative(rootDir, fullPath)
index[relativePath] = {
size: stat.size,
generatingIntegrity: limit(() => {
return stat.size < MAX_BULK_SIZE
? fs.readFile(fullPath).then(ssri.fromData)
: ssri.fromStream(fs.createReadStream(fullPath))
})
}
if (stat.isFile()) {
const relativePath = path.relative(rootDir, fullPath)
index[relativePath] = {
size: stat.size,
generatingIntegrity: limit(() => {
return stat.size < MAX_BULK_SIZE
? fs.readFile(fullPath).then(ssri.fromData)
: ssri.fromStream(fs.createReadStream(fullPath))
})
}
}
})
}
}))
})
.then(() => index)
.catch(err => {
return index
} catch (err) {
if (err.code !== 'ENOENT') {

@@ -48,3 +45,3 @@ throw err

return index
})
}
}

@@ -54,3 +51,3 @@

dirname = path.resolve(dirname)
return pEvery(Object.keys(dirIntegrity), f => {
return pEvery(Object.keys(dirIntegrity), async (f) => {
const fstat = dirIntegrity[f]

@@ -64,15 +61,17 @@

if (fstat.size > MAX_BULK_SIZE) {
return ssri.checkStream(fs.createReadStream(filename), fstat.integrity)
.catch(err => {
if (err.code === 'EINTEGRITY' || err.code === 'ENOENT') return false
throw err
})
try {
return await ssri.checkStream(fs.createReadStream(filename), fstat.integrity)
} catch (err) {
if (err.code === 'EINTEGRITY' || err.code === 'ENOENT') return false
throw err
}
}
return fs.readFile(filename)
.then(data => ssri.checkData(data, fstat.integrity))
.catch(err => {
if (err.code === 'EINTEGRITY' || err.code === 'ENOENT') return false
throw err
})
try {
const data = await fs.readFile(filename)
return ssri.checkData(data, fstat.integrity)
} catch (err) {
if (err.code === 'EINTEGRITY' || err.code === 'ENOENT') return false
throw err
}
}, {concurrency: 100})

@@ -79,0 +78,0 @@ }

{
"name": "dint",
"version": "3.0.2",
"version": "4.0.0",
"description": "Generate and verify directory integrity",

@@ -36,3 +36,3 @@ "main": "index.js",

"mz": "^2.7.0",
"p-every": "^1.0.2",
"p-every": "^2.0.0",
"p-limit": "^2.0.0",

@@ -44,3 +44,3 @@ "ssri": "^6.0.0"

"mos-plugin-readme": "^1.0.4",
"package-preview": "^1.0.1",
"package-preview": "^2.0.0",
"tape": "^4.6.3"

@@ -57,4 +57,4 @@ },

"engines": {
"node": ">=6"
"node": ">=8"
}
}

Sorry, the diff of this file is not supported yet

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