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.4.0 to 1.5.0

4

bin/spec-change.js

@@ -12,2 +12,3 @@ #!/usr/bin/env node

'--mask': String,
'--save-deps': String, // output filename
// aliases

@@ -31,4 +32,5 @@ '-f': '--folder',

const fileMask = args['--mask'] || '**/*.{js,ts}'
const deps = getDependsInFolder(folder, fileMask)
const saveDepsFilename = args['--save-deps']
const deps = getDependsInFolder(folder, fileMask, saveDepsFilename)
const depsStringified = JSON.stringify(deps, null, 2)
console.log(depsStringified + '\n')
{
"name": "spec-change",
"version": "1.4.0",
"version": "1.5.0",
"description": "Computes specs to re-run when files change",

@@ -10,3 +10,4 @@ "main": "src/index.js",

"demo1": "DEBUG=spec-change node ./bin/spec-change --folder fixtures/6",
"demo-mask": "DEBUG=spec-change node ./bin/spec-change --folder fixtures/6 --mask 'spec-b.js'"
"demo-mask": "DEBUG=spec-change node ./bin/spec-change --folder fixtures/6 --mask 'spec-b.js'",
"demo-save": "DEBUG=spec-change node ./bin/spec-change --folder fixtures/6 --save-deps deps.json"
},

@@ -13,0 +14,0 @@ "bin": {

@@ -29,2 +29,21 @@ # spec-change

You can save detected dependencies into a JSON file
```
$ npx spec-change --folder "path to folder" --mask '**/*.ts' --save-deps my-deps.json
```
The saved file will be something like:
```json
{
"folder": "relative path to folder",
"fileMask": "**/*.ts",
"deps": {
"utils/sub/misc.js": ["spec-b.ts"],
"spec-b.ts": ["spec-b.ts"]
}
}
```
### NPM module

@@ -89,2 +108,6 @@

## Examples
Used to [run affected Cypress specs first on CI](https://glebbahmutov.com/blog/trace-changed-specs/)
## Small print

@@ -91,0 +114,0 @@

@@ -6,2 +6,3 @@ const dependencyTree = require('dependency-tree')

const globby = require('globby')
const fs = require('fs')

@@ -140,4 +141,9 @@ function isOutside(relativePath) {

* @param {string} fileMask Optional file mask to use to find the source files
* @param {string} saveDepsFilename Optional filename to save JSON of found dependencies
*/
function getDependsInFolder(folder, fileMask = '**/*.{js,ts}') {
function getDependsInFolder(
folder,
fileMask = '**/*.{js,ts}',
saveDepsFilename,
) {
la(path.isAbsolute(folder), 'expected an absolute folder path', folder)

@@ -155,2 +161,14 @@ la(typeof fileMask === 'string', 'expected a file mask', fileMask)

const deps = getDependentFiles(files, folder)
if (saveDepsFilename) {
debug('saving json file with dependencies %s', saveDepsFilename)
// use relative folder
const relativeFolder = path.relative(process.cwd(), folder)
const fullInfo = {
folder: relativeFolder,
fileMask,
deps,
}
const s = JSON.stringify(fullInfo, null, 2) + '\n\n'
fs.writeFileSync(saveDepsFilename, s, 'utf8')
}
return deps

@@ -157,0 +175,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