Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

spec-change

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spec-change - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

2

package.json
{
"name": "spec-change",
"version": "1.3.0",
"version": "1.4.0",
"description": "Computes specs to re-run when files change",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -72,2 +72,14 @@ # spec-change

#### affectedFiles
Takes the dependencies computed using `getDependsInFolder` or `getDependentFiles` and a list of source files and produces a list of potentially affected files.
```js
const { getDependsInFolder, affectedFiles } = require('spec-change')
const deps = getDependsInFolder(directory)
const changedFiles = ['utils/sub/misc.js']
const affected = affectedFiles(deps, changedFiles)
// a list of files that depend on the misc file
```
## Debugging

@@ -74,0 +86,0 @@

@@ -133,2 +133,9 @@ const dependencyTree = require('dependency-tree')

/**
* Give the folder name and optional file mask, finds dependencies between all files.
* The returned object can have _other_ files, if they are imported or required
* from the source files.
* @param {string} folder Absolute path to the folder
* @param {string} fileMask Optional file mask to use to find the source files
*/
function getDependsInFolder(folder, fileMask = '**/*.{js,ts}') {

@@ -150,2 +157,26 @@ la(path.isAbsolute(folder), 'expected an absolute folder path', folder)

/**
* Given the computed dependencies object and a list of files,
* returns a list of files that are affected by the changes.
* Useful when the files are computed using source control changes
* and now we want to verify _all_ potentially affected source files.
* @see `getDependsInFolder`
* @param {Object} deps Source file dependencies computed using `getDependentFiles` or `getDependsInFolder`
* @param {string[]} filenames List of filenames (relative) that have changed
* @returns {string[]}
*/
function affectedFiles(deps, filenames) {
const affected = new Set()
filenames.forEach((filename) => {
if (deps[filename]) {
const filesAffectedByThisChangedFile = deps[filename]
filesAffectedByThisChangedFile.forEach((name) => {
affected.add(name)
})
}
})
return [...affected].sort()
}
module.exports = {

@@ -157,2 +188,3 @@ getFileDependencies,

getDependsInFolder,
affectedFiles,
}
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