Skip to content

Conversation

@brendankenny
Copy link
Contributor

@brendankenny brendankenny commented Jan 13, 2022

Inspired by recent discussion about churn in newlines at the end of files updated by yarn update:sample-artifacts vs .editorconfig's insert_final_newline = true when editing one of the artifact files manually. The scripted update should match the repo style, just like we do with yarn update:sample-json.

Turns out saveArtifacts() already saved the main artifacts and trace files with trailing newlines, so only the devtoolsLog files needed updating. update-report-fixtures.js also needed tweaking to not second guess saveArtifacts().

@brendankenny brendankenny requested a review from a team as a code owner January 13, 2022 01:49
@brendankenny brendankenny requested review from adamraine and removed request for a team January 13, 2022 01:49
// don't need anything in this file except for `stringifyReplacer`, so a check for
// truthiness before using is enough.
// TODO: Can remove promisify(pipeline) in Node 15.
// https://nodejs.org/api/stream.html#streams-promises-api
Copy link
Contributor Author

@brendankenny brendankenny Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just moving the TODO to see it more easily with the other workaround that can eventually be removed


let newArtifacts = assetSaver.loadArtifacts(artifactPath);

// Normalize some data so it doesn't change on every update.
Copy link
Contributor Author

@brendankenny brendankenny Jan 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file was making new artifacts, saving them with saveArtifacts(), loading them again to normalize churn-y Timing, then doing its own fs.writeFileSync(). Normalization should just happen before the first (and only) save, which also means the concluding newline added by saveArtifacts() will be in the resulting file.

{args: {IsMainFrame: true}, cat: 'v8', pid: 1, ts: 5},
{args: {data: {encodedDataLength: 20, requestId: '1.22'}}, pid: 1, ts: 6},
],
metadata: {'cpu-model': 9001, 'network-type': 'Unknown'},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not directly important to Lighthouse, but overlooked in previous testing of saveTrace() and very relevant to where the various methods are putting newlines within their output :)

Comment on lines +256 to +257
yield* arrayOfObjectsJsonGenerator(devtoolsLog);
yield '\n';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First time seeing yield in JS, lemme just google that quick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants