@@ -14,6 +14,9 @@ import 'package:yaml/yaml.dart';
14
14
/// A regular expression that matches a version in a pubspec.
15
15
final _pubspecVersionRegExp = RegExp (r'^version: (.*)$' , multiLine: true );
16
16
17
+ /// A regular expression that matches a Sass dependency version in a pubspec.
18
+ final _sassVersionRegExp = RegExp (r'^( +)sass: (\d.*)$' , multiLine: true );
19
+
17
20
/// Adds grinder tasks for bumping package versions.
18
21
void addBumpVersionTasks () {
19
22
for (var patch in [false , true ]) {
@@ -72,18 +75,33 @@ void _bumpVersion(bool patch, bool dev) {
72
75
73
76
// Bumps the current version of [pubspec] to the next [patch] version, with
74
77
// `-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]) {
76
83
var text = File (path).readAsStringSync ();
77
84
var pubspec = loadYaml (text, sourceUrl: p.toUri (path)) as YamlMap ;
78
85
var version = chooseNextVersion (Version .parse (pubspec["version" ] as String ),
79
86
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);
82
99
addChangelogEntry (p.dirname (path), version);
100
+ return version;
83
101
}
84
102
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 );
87
105
88
106
var packageJsonPath = 'pkg/sass-parser/package.json' ;
89
107
var packageJsonText = File (packageJsonPath).readAsStringSync ();
0 commit comments