Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions benchmarkFixture.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { fileURLToPath } from 'node:url'

import spawn from 'cross-spawn'
import getFolderSize from 'get-folder-size'
import YAML from 'js-yaml'
import pathKey from 'path-key'
import rimraf from 'rimraf'
import tempy from 'tempy'
Expand Down Expand Up @@ -247,12 +248,18 @@ export function pnpmWorkspaceYaml (opts = {}) {
}

/**
* Serializes a config file that is read as YAML. JSON is valid YAML, and
* `JSON.stringify` quotes and escapes every value correctly, which
* hand-written YAML does only for values that happen not to need it.
* Serializes a config file that is read as YAML. A serializer quotes and
* escapes every value correctly, which hand-written YAML does only for values
* that happen not to need it.
*
* The output must be block-style YAML, not JSON: pnpm edits
* `pnpm-workspace.yaml` in place (`--allow-build` records `allowBuilds`
* there), and it refuses to edit a document that is a multi-line flow
* collection. `noRefs` keeps shared objects from being written as aliases,
* which pnpm cannot edit either.
*/
export function yamlText (value) {
return `${JSON.stringify(value, null, 2)}\n`
return YAML.dump(value, { noRefs: true })
}

/**
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"dependencies": {
"cross-spawn": "^7.0.3",
"get-folder-size": "^3.1.0",
"js-yaml": "^4.3.2",
"load-yaml-file": "^1.0.0",
"path-key": "^4.0.0",
"rimraf": "^4.0.0",
Expand Down
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading