Skip to content

Commit

Permalink
Isolate use of json-stringify-safe.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Jan 9, 2017
1 parent d328101 commit 0bb1742
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
7 changes: 4 additions & 3 deletions lighthouse-core/lib/asset-saver.js
Expand Up @@ -18,7 +18,7 @@

const fs = require('fs');
const log = require('../../lighthouse-core/lib/log.js');
const stringify = require('json-stringify-safe');
const stringifySafe = require('json-stringify-safe');

function getFilenamePrefix(options) {
const url = options.url;
Expand Down Expand Up @@ -81,7 +81,8 @@ img {
/* istanbul ignore next */
function saveArtifacts(artifacts, filename) {
const artifactsFilename = filename || 'artifacts.log';
fs.writeFileSync(artifactsFilename, stringify(artifacts));
// The networkRecords artifacts have circular references
fs.writeFileSync(artifactsFilename, stringifySafe(artifacts));
log.log('artifacts file saved to disk', artifactsFilename);
}

Expand Down Expand Up @@ -125,7 +126,7 @@ function saveAssets(options, artifacts) {
const filenamePrefix = getFilenamePrefix(options);

const traceData = data.traceData;
fs.writeFileSync(`${filenamePrefix}-${index}.trace.json`, stringify(traceData, null, 2));
fs.writeFileSync(`${filenamePrefix}-${index}.trace.json`, JSON.stringify(traceData, null, 2));
log.log('trace file saved to disk', filenamePrefix);

fs.writeFileSync(`${filenamePrefix}-${index}.screenshots.html`, data.html);
Expand Down
3 changes: 1 addition & 2 deletions lighthouse-core/report/report-generator.js
Expand Up @@ -20,7 +20,6 @@

const Formatter = require('../formatters/formatter');
const Handlebars = require('handlebars');
const stringify = require('json-stringify-safe');
const fs = require('fs');
const path = require('path');
const marked = require('marked');
Expand Down Expand Up @@ -252,7 +251,7 @@ class ReportGenerator {
errMessage: err.message,
errStack: err.stack,
css: this.getReportCSS(),
results: stringify(results, null, 2)
results: JSON.stringify(results, null, 2)
});
}

Expand Down

0 comments on commit 0bb1742

Please sign in to comment.