spec-change
Advanced tools
Comparing version 1.9.0 to 1.10.0
{ | ||
"name": "spec-change", | ||
"version": "1.9.0", | ||
"version": "1.10.0", | ||
"description": "Computes specs to re-run when files change", | ||
@@ -35,2 +35,3 @@ "main": "src/index.js", | ||
"debug": "^4.3.4", | ||
"deep-equal": "^2.2.3", | ||
"dependency-tree": "^10.0.9", | ||
@@ -37,0 +38,0 @@ "globby": "^11.1.0", |
@@ -39,2 +39,3 @@ # spec-change | ||
{ | ||
"generatedAt": "2024-01-20T03:38:50.803Z", | ||
"folder": "relative path to folder", | ||
@@ -49,2 +50,4 @@ "fileMask": "**/*.ts", | ||
**Note:** the file will NOT be written if the folder, file mask, and the dependencies tree is the same. | ||
You can check how long finding files and dependencies takes by adding `--time` boolean flag. Note: the info is printed to `STDERR` stream | ||
@@ -51,0 +54,0 @@ |
@@ -8,2 +8,3 @@ // https://github.com/dependents/node-dependency-tree | ||
const fs = require('fs') | ||
const deepEqual = require('deep-equal') | ||
@@ -154,3 +155,4 @@ function isOutside(relativePath) { | ||
debug('options %o', options) | ||
const { folder, saveDepsFilename, allowJs } = options | ||
const { folder, allowJs } = options | ||
let { saveDepsFilename } = options | ||
const fileMask = options.fileMask || '**/*.{js,jsx,ts,tsx}' | ||
@@ -173,15 +175,33 @@ | ||
if (saveDepsFilename) { | ||
debug('saving json file with dependencies %s', saveDepsFilename) | ||
// use relative folder | ||
const relativeFolder = path.relative(process.cwd(), folder) | ||
const fullInfo = { | ||
warning: | ||
'This is a machine-generated file, do not modify it manually. Use https://github.com/bahmutov/spec-change', | ||
generatedAt: new Date().toISOString(), | ||
folder: relativeFolder, | ||
fileMask, | ||
deps, | ||
if (fs.existsSync(saveDepsFilename)) { | ||
const oldDeps = JSON.parse(fs.readFileSync(saveDepsFilename, 'utf8')) | ||
const sameFolder = oldDeps.folder === relativeFolder | ||
const sameMask = oldDeps.fileMask === fileMask | ||
const sameDependencies = deepEqual(oldDeps.deps, deps) | ||
debug({ sameFolder, sameMask, sameDependencies }) | ||
if (sameFolder && sameMask && sameDependencies) { | ||
saveDepsFilename = false | ||
} | ||
} | ||
const s = JSON.stringify(fullInfo, null, 2) + '\n\n' | ||
fs.writeFileSync(saveDepsFilename, s, 'utf8') | ||
if (saveDepsFilename) { | ||
debug('saving json file with dependencies %s', saveDepsFilename) | ||
const fullInfo = { | ||
warning: | ||
'This is a machine-generated file, do not modify it manually. Use https://github.com/bahmutov/spec-change', | ||
generatedAt: new Date().toISOString(), | ||
folder: relativeFolder, | ||
fileMask, | ||
deps, | ||
} | ||
const s = JSON.stringify(fullInfo, null, 2) + '\n\n' | ||
fs.writeFileSync(saveDepsFilename, s, 'utf8') | ||
console.log('saved dependencies file %s', saveDepsFilename) | ||
} else { | ||
console.log('skipping saving dependencies file') | ||
} | ||
} | ||
@@ -188,0 +208,0 @@ const finished = +new Date() |
15069
260
145
6
+ Addeddeep-equal@^2.2.3
+ Addedarray-buffer-byte-length@1.0.2(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.8(transitive)
+ Addedcall-bind-apply-helpers@1.0.1(transitive)
+ Addedcall-bound@1.0.3(transitive)
+ Addeddeep-equal@2.2.3(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addeddunder-proto@1.0.1(transitive)
+ Addedes-define-property@1.0.1(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-get-iterator@1.1.3(transitive)
+ Addedes-object-atoms@1.1.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.7(transitive)
+ Addedget-proto@1.0.1(transitive)
+ Addedgopd@1.2.0(transitive)
+ Addedhas-bigints@1.1.0(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-symbols@1.1.0(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedinternal-slot@1.1.0(transitive)
+ Addedis-arguments@1.2.0(transitive)
+ Addedis-array-buffer@3.0.5(transitive)
+ Addedis-bigint@1.1.0(transitive)
+ Addedis-boolean-object@1.2.1(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-date-object@1.1.0(transitive)
+ Addedis-map@2.0.3(transitive)
+ Addedis-number-object@1.1.1(transitive)
+ Addedis-regex@1.2.1(transitive)
+ Addedis-set@2.0.3(transitive)
+ Addedis-shared-array-buffer@1.0.4(transitive)
+ Addedis-string@1.1.1(transitive)
+ Addedis-symbol@1.1.1(transitive)
+ Addedis-weakmap@2.0.2(transitive)
+ Addedis-weakset@2.0.4(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedmath-intrinsics@1.1.0(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-is@1.1.6(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.7(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedregexp.prototype.flags@1.5.4(transitive)
+ Addedsafe-regex-test@1.1.0(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.1.0(transitive)
+ Addedside-channel-list@1.0.0(transitive)
+ Addedside-channel-map@1.0.1(transitive)
+ Addedside-channel-weakmap@1.0.2(transitive)
+ Addedstop-iteration-iterator@1.1.0(transitive)
+ Addedwhich-boxed-primitive@1.1.1(transitive)
+ Addedwhich-collection@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.18(transitive)