New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

snap-shot-core

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snap-shot-core - npm Package Compare versions

Comparing version 7.1.0 to 7.1.1

src/prune.js

12

package.json
{
"name": "snap-shot-core",
"description": "Save / load named snapshots, useful for tests",
"version": "7.1.0",
"version": "7.1.1",
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>",

@@ -26,2 +26,4 @@ "bugs": "https://github.com/bahmutov/snap-shot-core/issues",

"npm run ban -- --all",
"echo checking if package lock has been updated by running npm ci command",
"npm ci",
"npm run size"

@@ -87,8 +89,2 @@ ],

]
},
"verifyRelease": {
"path": "dont-crack",
"test-against": [
"https://github.com/bahmutov/snap-shot-it"
]
}

@@ -101,7 +97,5 @@ },

"disparity": "2.0.0",
"dont-crack": "1.2.1",
"git-issues": "1.3.1",
"license-checker": "20.2.0",
"mocha": "5.2.0",
"next-update-travis": "1.7.1",
"nsp": "3.2.1",

@@ -108,0 +102,0 @@ "pre-git": "3.17.1",

@@ -9,3 +9,3 @@ 'use strict'

const isCI = require('is-ci')
const R = require('ramda')
const snapshotIndex = utils.snapshotIndex

@@ -22,4 +22,2 @@ const strip = utils.strip

const DEFAULT_EXTENSION = '.snapshot.js'
const identity = x => x

@@ -161,36 +159,2 @@

const pruneSnapshotsInFile = ({ byFilename, ext }) => file => {
const runtimeSnapshots = byFilename[file]
const specNames = R.map(R.prop('specName', runtimeSnapshots))
const snapshots = fs.loadSnapshots(file, ext)
if (is.empty(snapshots)) {
debug('empty snapshot file for', file)
return
}
const isPresent = (val, key) => {
return R.find(specName => key.startsWith(specName))(specNames)
}
const prunedSnapshots = R.pickBy(isPresent, snapshots)
if (R.equals(prunedSnapshots, snapshots)) {
debug('nothing to prune for file', file)
return
}
debug('saving pruned snapshot file for', file)
fs.saveSnapshots(file, prunedSnapshots, ext)
}
// TODO switch to async id:3
// Gleb Bahmutov
// gleb.bahmutov@gmail.com
// https://github.com/bahmutov/snap-shot-core/issues/88
function pruneSnapshots ({ tests, ext = DEFAULT_EXTENSION }) {
la(is.array(tests), 'missing tests', tests)
const byFilename = R.groupBy(R.prop('file'), tests)
debug('pruning snapshots')
debug('run time tests')
debug(tests)
Object.keys(byFilename).forEach(pruneSnapshotsInFile({ byFilename, ext }))
}
const isPromise = x => is.object(x) && is.fn(x.then)

@@ -207,3 +171,3 @@

const raiser = options.raiser || fs.raiseIfDifferent
const ext = options.ext || DEFAULT_EXTENSION
const ext = options.ext || utils.DEFAULT_EXTENSION
const comment = options.comment

@@ -327,2 +291,4 @@ const opts = options.opts || {}

const prune = require('./prune')(fs).pruneSnapshots
// snapShotCore.restore = restore

@@ -334,3 +300,3 @@ // snapShotCore.prune = pruneSnapshots

restore,
prune: pruneSnapshots
prune
}

@@ -54,3 +54,3 @@ 'use strict'

const compareTypes = (options) => {
const compareTypes = options => {
const expected = options.expected

@@ -86,3 +86,3 @@ const value = options.value

const isSurroundedByNewLines = (s) =>
const isSurroundedByNewLines = s =>
is.string(s) && s.length > 1 && s[0] === '\n' && s[s.length - 1] === '\n'

@@ -104,2 +104,4 @@

const DEFAULT_EXTENSION = '.snapshot.js'
module.exports = {

@@ -113,3 +115,4 @@ snapshotIndex,

exportObject,
removeExtraNewLines
removeExtraNewLines,
DEFAULT_EXTENSION
}
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