spec-change
Advanced tools
Comparing version
{ | ||
"name": "spec-change", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Computes specs to re-run when files change", | ||
@@ -8,4 +8,12 @@ "main": "src/index.js", | ||
"test": "ava", | ||
"semantic-release": "semantic-release" | ||
"semantic-release": "semantic-release", | ||
"demo1": "DEBUG=spec-change node ./bin/spec-change --folder fixtures/6" | ||
}, | ||
"bin": { | ||
"spec-change": "bin/spec-change.js" | ||
}, | ||
"files": [ | ||
"src", | ||
"bin" | ||
], | ||
"keywords": [], | ||
@@ -21,2 +29,5 @@ "author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
"dependencies": { | ||
"arg": "^5.0.2", | ||
"debug": "^4.3.4", | ||
"globby": "^11.1.0", | ||
"lazy-ass": "^2.0.3" | ||
@@ -23,0 +34,0 @@ }, |
@@ -5,2 +5,21 @@ # spec-change | ||
## Use | ||
### CLI | ||
``` | ||
$ npx spec-change --folder "path to folder with specs" | ||
``` | ||
Prints a JSON object with the list of JavaScript files. For each file prints the list of dependent files. For example, if `spec.js` imports or requires `utils.js` file, then it will print something like: | ||
```json | ||
{ | ||
"spec.js": ["spec.js"], | ||
"utils.js": ["spec.js"] | ||
} | ||
``` | ||
### NPM module | ||
Based on the `import` and `require` directives. | ||
@@ -10,2 +29,3 @@ | ||
const { getDependentFiles } = require('spec-change') | ||
// the input paths should be absolute | ||
const deps = getDependentFiles([ | ||
@@ -25,8 +45,13 @@ 'path/to/spec1.js', | ||
'path/to/spec2.js': ['path/to/spec2.js'], | ||
// the spec2 imports something from utils | ||
'path/to/utils.js': ['path/to/spec2.js'], | ||
... | ||
// the specs spec2 and spec3 imports something from utils | ||
'path/to/utils.js': ['path/to/spec2.js', 'path/to/spec3.js'], | ||
... | ||
} | ||
``` | ||
## Debugging | ||
Run this code with environment variable `DEBUG=spec-change` | ||
## Small print | ||
@@ -33,0 +58,0 @@ |
@@ -80,2 +80,5 @@ const dependencyTree = require('dependency-tree') | ||
* is a relative filename. The value is a list of _other_ files that depend on it | ||
* @param {string[]} filenames The absolute filenames to the source files | ||
* @param {string} directory The absolute path to the common directory | ||
* @see https://github.com/bahmutov/spec-change | ||
*/ | ||
@@ -82,0 +85,0 @@ function getDependentFiles(filenames, directory) { |
71
54.35%8336
-45.93%4
300%5
-88.1%133
-43.64%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added