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.2.2 to 1.3.0

12

bin/spec-change.js

@@ -5,11 +5,12 @@ #!/usr/bin/env node

const debug = require('debug')('spec-change')
const globby = require('globby')
const path = require('path')
const fs = require('fs')
const { getDependentFiles } = require('../src')
const { getDependsInFolder } = require('../src')
const args = arg({
'--folder': String,
'--mask': String,
// aliases
'-f': '--folder',
'-m': '--mask',
})

@@ -29,8 +30,5 @@

const folder = path.resolve(args['--folder'])
debug('absolute folder: %s', folder)
const files = globby.sync(folder + '/**/*.{js,ts}')
debug('found %d files %o', files.length, files)
const deps = getDependentFiles(files, folder)
const fileMask = args['--mask'] || '**/*.{js,ts}'
const deps = getDependsInFolder(folder, fileMask)
const depsStringified = JSON.stringify(deps, null, 2)
console.log(depsStringified + '\n')
{
"name": "spec-change",
"version": "1.2.2",
"version": "1.3.0",
"description": "Computes specs to re-run when files change",

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

"semantic-release": "semantic-release",
"demo1": "DEBUG=spec-change node ./bin/spec-change --folder fixtures/6"
"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'"
},

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

@@ -22,6 +22,15 @@ # spec-change

You can specify the file mask
```
# start the search from TS files only
$ npx spec-change --folder "path to folder" --mask '**/*.ts'
```
### NPM module
Based on the `import` and `require` directives.
All files are found using the `import` and `require` directives.
#### getDependentFiles
```js

@@ -51,2 +60,15 @@ const { getDependentFiles } = require('spec-change')

#### getDependsInFolder
Finds the source files in the given folder and returns the dependencies object (just like above)
```js
const { getDependsInFolder } = require('spec-change')
// see the "bin/spec-change.js" for example
const deps = getDependsInFolder(
'/absolute/path/to/folder',
(fileMask = '**/*.{js,ts}'),
)
```
## Debugging

@@ -53,0 +75,0 @@

const dependencyTree = require('dependency-tree')
const path = require('path')
const { lazyAss: la } = require('lazy-ass')
const debug = require('debug')('spec-change')
const globby = require('globby')

@@ -131,2 +133,18 @@ function isOutside(relativePath) {

function getDependsInFolder(folder, fileMask = '**/*.{js,ts}') {
la(path.isAbsolute(folder), 'expected an absolute folder path', folder)
la(typeof fileMask === 'string', 'expected a file mask', fileMask)
debug('absolute folder: %s', folder)
debug('file mask: %s', fileMask)
const files = globby.sync(fileMask, {
cwd: folder,
absolute: true,
})
debug('found %d files %o', files.length, files)
const deps = getDependentFiles(files, folder)
return deps
}
module.exports = {

@@ -137,2 +155,3 @@ getFileDependencies,

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