Skip to content

Better yaml serialization for pubspec.lock #4214

Open
@sigurdm

Description

@sigurdm

Sometimes the content hash is quoted, sometimes not.

image

We use a quite naive yaml serialization for writing pubspec.lock.

Here is the regex that decides is a string needs to be json-encoded before serializing:

final _unquotableYamlString = RegExp(r'^[a-zA-Z_-][a-zA-Z_0-9-]*$');

/// The subset of strings that don't need quoting in YAML.
///
/// This pattern does not strictly follow the plain scalar grammar of YAML,
/// which means some strings may be unnecessarily quoted, but it's much simpler.
final _unquotableYamlString = RegExp(r'^[a-zA-Z_-][a-zA-Z_0-9-]*$');

We could consider using yaml_edit to write the pubspec.lock file

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions