Skip to content

Commit 5c63839

Browse files
authored
Bump the sass_api dependency along with package versions (#2408)
1 parent 477b596 commit 5c63839

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

tool/grind/bump_version.dart

+23-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import 'package:yaml/yaml.dart';
1414
/// A regular expression that matches a version in a pubspec.
1515
final _pubspecVersionRegExp = RegExp(r'^version: (.*)$', multiLine: true);
1616

17+
/// A regular expression that matches a Sass dependency version in a pubspec.
18+
final _sassVersionRegExp = RegExp(r'^( +)sass: (\d.*)$', multiLine: true);
19+
1720
/// Adds grinder tasks for bumping package versions.
1821
void addBumpVersionTasks() {
1922
for (var patch in [false, true]) {
@@ -72,18 +75,33 @@ void _bumpVersion(bool patch, bool dev) {
7275

7376
// Bumps the current version of [pubspec] to the next [patch] version, with
7477
// `-dev` if [dev] is true.
75-
void bumpDartVersion(String path) {
78+
//
79+
// If [sassVersion] is passed, this bumps the `sass` dependency to that version.
80+
//
81+
// Returns the new version of this package.
82+
Version bumpDartVersion(String path, [Version? sassVersion]) {
7683
var text = File(path).readAsStringSync();
7784
var pubspec = loadYaml(text, sourceUrl: p.toUri(path)) as YamlMap;
7885
var version = chooseNextVersion(Version.parse(pubspec["version"] as String),
7986
pubspec.nodes["version"]!.span);
80-
File(path).writeAsStringSync(
81-
text.replaceFirst(_pubspecVersionRegExp, 'version: $version'));
87+
88+
text = text.replaceFirst(_pubspecVersionRegExp, 'version: $version');
89+
if (sassVersion != null) {
90+
// Don't depend on a prerelease version, depend on its released
91+
// equivalent.
92+
var sassDependencyVersion =
93+
Version(sassVersion.major, sassVersion.minor, sassVersion.patch);
94+
text = text.replaceFirstMapped(_sassVersionRegExp,
95+
(match) => '${match[1]}sass: $sassDependencyVersion');
96+
}
97+
98+
File(path).writeAsStringSync(text);
8299
addChangelogEntry(p.dirname(path), version);
100+
return version;
83101
}
84102

85-
bumpDartVersion('pubspec.yaml');
86-
bumpDartVersion('pkg/sass_api/pubspec.yaml');
103+
var sassVersion = bumpDartVersion('pubspec.yaml');
104+
bumpDartVersion('pkg/sass_api/pubspec.yaml', sassVersion);
87105

88106
var packageJsonPath = 'pkg/sass-parser/package.json';
89107
var packageJsonText = File(packageJsonPath).readAsStringSync();

0 commit comments

Comments
 (0)