Skip to content

Commit e110961

Browse files
authored
Pass the version variable to script snapshots at build time (#920)
Closes #914 See dart-lang/sdk#36579 (comment)
1 parent bfdf4b3 commit e110961

File tree

10 files changed

+19
-22
lines changed

10 files changed

+19
-22
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.24.3
2+
3+
* Fix a bug where `sass --version` would crash for certain executable
4+
distributions.
5+
16
## 1.24.2
27

38
* Fix a bug introduced in the previous release that prevented custom importers

package/chocolatey/sass.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ REM https://opensource.org/licenses/MIT.
55

66
set SCRIPTPATH=%~dp0
77
set arguments=%*
8-
dart.exe "-Dversion=SASS_VERSION" "%SCRIPTPATH%\sass.dart.snapshot" %arguments%
8+
dart.exe "%SCRIPTPATH%\sass.dart.snapshot" %arguments%

package/dart-sass.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ echo "WARNING: The dart-sass executable is deprecated, use sass instead."
1111

1212
set SCRIPTPATH=%~dp0
1313
set arguments=%*
14-
"%SCRIPTPATH%\src\dart.exe" "-Dversion=SASS_VERSION" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments%
14+
"%SCRIPTPATH%\src\dart.exe" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments%

package/dart-sass.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,4 @@ fi
2222

2323
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
2424
path=`dirname "$(follow_links "$BASH_SOURCE")"`
25-
exec "$path/src/dart" "-Dversion=SASS_VERSION" "$path/src/sass.dart.snapshot" "$@"
25+
exec "$path/src/dart" "$path/src/sass.dart.snapshot" "$@"

package/sass.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ REM grinder package`.
99

1010
set SCRIPTPATH=%~dp0
1111
set arguments=%*
12-
"%SCRIPTPATH%\src\dart.exe" "-Dversion=SASS_VERSION" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments%
12+
"%SCRIPTPATH%\src\dart.exe" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments%

package/sass.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ follow_links() {
1818

1919
# Unlike $0, $BASH_SOURCE points to the absolute path of this file.
2020
path=`dirname "$(follow_links "$0")"`
21-
exec "$path/src/dart" "-Dversion=SASS_VERSION" "$path/src/sass.dart.snapshot" "$@"
21+
exec "$path/src/dart" "$path/src/sass.dart.snapshot" "$@"

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: sass
2-
version: 1.24.2
2+
version: 1.24.3
33
description: A Sass implementation in Dart.
44
author: Sass Team
55
homepage: https://github.com/sass/dart-sass

tool/grind/chocolatey.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ void chocolateyPackage() {
3232
"package/chocolatey/chocolateyInstall.ps1"))
3333
..addFile(file("tools/chocolateyUninstall.ps1",
3434
"package/chocolatey/chocolateyUninstall.ps1"))
35-
..addFile(fileFromString("tools/sass.bat",
36-
readAndReplaceVersion("package/chocolatey/sass.bat")));
35+
..addFile(file("tools/sass.bat", "package/chocolatey/sass.bat"));
3736

3837
var output = "build/sass.${_chocolateyVersion()}.nupkg";
3938
log("Creating $output...");

tool/grind/standalone.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ bool get _is64Bit => Platform.version.contains("x64");
1818
@Task('Build Dart script snapshot.')
1919
void snapshot() {
2020
ensureBuild();
21-
Dart.run('bin/sass.dart', vmArgs: ['--snapshot=build/sass.dart.snapshot']);
21+
Dart.run('bin/sass.dart',
22+
vmArgs: ['-Dversion=$version', '--snapshot=build/sass.dart.snapshot']);
2223
}
2324

2425
@Task('Build a dev-mode Dart application snapshot.')
@@ -42,6 +43,7 @@ void _appSnapshot() {
4243
arguments: ['tool/app-snapshot-input.scss'],
4344
vmArgs: [
4445
'--enable-asserts',
46+
'-Dversion=$version',
4547
'--snapshot=build/sass.dart.app.snapshot',
4648
'--snapshot-kind=app-jit'
4749
],
@@ -103,15 +105,11 @@ Future<void> _buildPackage(String os) async {
103105
..addFile(file("dart-sass/src/sass.dart.snapshot",
104106
useNative ? "build/sass.dart.native" : "build/sass.dart.snapshot"))
105107
..addFile(file("dart-sass/src/SASS_LICENSE", "LICENSE"))
106-
..addFile(fileFromString(
107-
"dart-sass/dart-sass${os == 'windows' ? '.bat' : ''}",
108-
readAndReplaceVersion(
109-
"package/dart-sass.${os == 'windows' ? 'bat' : 'sh'}"),
108+
..addFile(file("dart-sass/dart-sass${os == 'windows' ? '.bat' : ''}",
109+
"package/dart-sass.${os == 'windows' ? 'bat' : 'sh'}",
110110
executable: true))
111-
..addFile(fileFromString(
112-
"dart-sass/sass${os == 'windows' ? '.bat' : ''}",
113-
readAndReplaceVersion(
114-
"package/sass.${os == 'windows' ? 'bat' : 'sh'}"),
111+
..addFile(file("dart-sass/sass${os == 'windows' ? '.bat' : ''}",
112+
"package/sass.${os == 'windows' ? 'bat' : 'sh'}",
115113
executable: true));
116114

117115
var prefix = 'build/dart-sass-$version-$os-$architecture';

tool/grind/utils.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ void ensureBuild() {
3535
Directory('build').createSync(recursive: true);
3636
}
3737

38-
/// Reads [file], replaces all instances of SASS_VERSION with the actual
39-
/// version, and returns its contents.
40-
String readAndReplaceVersion(String file) =>
41-
File(file).readAsStringSync().replaceAll("SASS_VERSION", version);
42-
4338
/// Returns the environment variable named [name], or throws an exception if it
4439
/// can't be found.
4540
String environment(String name) {

0 commit comments

Comments
 (0)