snap-shot-core
Advanced tools
Comparing version 7.4.0 to 8.0.0
{ | ||
"name": "snap-shot-core", | ||
"description": "Save / load named snapshots, useful for tests", | ||
"version": "7.4.0", | ||
"version": "8.0.0", | ||
"author": "Gleb Bahmutov <gleb.bahmutov@gmail.com>", | ||
@@ -100,8 +100,8 @@ "bugs": "https://github.com/bahmutov/snap-shot-core/issues", | ||
"license-checker": "25.0.1", | ||
"mocha": "6.0.2", | ||
"mocha": "6.1.2", | ||
"pre-git": "3.17.1", | ||
"semantic-release": "15.13.3", | ||
"simple-commit-message": "4.0.3", | ||
"sinon": "7.3.0", | ||
"snap-shot-it": "6.3.1", | ||
"sinon": "7.3.1", | ||
"snap-shot-it": "6.3.2", | ||
"standard": "12.0.1", | ||
@@ -108,0 +108,0 @@ "stop-only": "2.2.5" |
@@ -250,2 +250,6 @@ [![TODO board](https://imdone.io/api/1.0/projects/5b1adebb4f7fd004e58ef569/badge)](https://imdone.io/app#/board/bahmutov/snap-shot-core) | ||
## Escaping values | ||
Because the snapshots are saved as template literals, back ticks and other "niceties" have to be escaped. This module uses [jsesc](https://github.com/mathiasbynens/jsesc) module to do string escaping. Currently only the [minimal set of characters is escaped](https://github.com/mathiasbynens/jsesc#minimal). | ||
## Resaving snaphots | ||
@@ -252,0 +256,0 @@ |
@@ -60,2 +60,7 @@ 'use strict' | ||
/** | ||
* Serializes and escapes a string value before saving. | ||
* @param {string} name for the snapshot | ||
* @param {string} value text to be escaped for saving | ||
*/ | ||
function exportText (name, value) { | ||
@@ -80,3 +85,4 @@ la(is.unemptyString(name), 'expected snapshot name, got:', name) | ||
return jsesc(line, { | ||
quotes: 'backtick' | ||
quotes: 'backtick', | ||
minimal: true | ||
}) | ||
@@ -89,2 +95,5 @@ }) | ||
/** | ||
* Escapes properties of an object to be safe for saving | ||
*/ | ||
function exportObject (name, value) { | ||
@@ -94,3 +103,4 @@ const serialized = jsesc(value, { | ||
compact: false, | ||
indent: ' ' | ||
indent: ' ', | ||
minimal: true | ||
}) | ||
@@ -97,0 +107,0 @@ return `exports['${name}'] = ${serialized}\n` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
38354
814
314