From e110961120298c2d56f95db74d777ef3b62771ac Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Tue, 7 Jan 2020 13:53:30 -0800 Subject: [PATCH] Pass the version variable to script snapshots at build time (#920) Closes #914 See https://github.com/dart-lang/sdk/issues/36579#issuecomment-571386118 --- CHANGELOG.md | 5 +++++ package/chocolatey/sass.bat | 2 +- package/dart-sass.bat | 2 +- package/dart-sass.sh | 2 +- package/sass.bat | 2 +- package/sass.sh | 2 +- pubspec.yaml | 2 +- tool/grind/chocolatey.dart | 3 +-- tool/grind/standalone.dart | 16 +++++++--------- tool/grind/utils.dart | 5 ----- 10 files changed, 19 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d01aa90..dc450440 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.24.3 + +* Fix a bug where `sass --version` would crash for certain executable + distributions. + ## 1.24.2 * Fix a bug introduced in the previous release that prevented custom importers diff --git a/package/chocolatey/sass.bat b/package/chocolatey/sass.bat index 954937b0..b15afb0d 100644 --- a/package/chocolatey/sass.bat +++ b/package/chocolatey/sass.bat @@ -5,4 +5,4 @@ REM https://opensource.org/licenses/MIT. set SCRIPTPATH=%~dp0 set arguments=%* -dart.exe "-Dversion=SASS_VERSION" "%SCRIPTPATH%\sass.dart.snapshot" %arguments% +dart.exe "%SCRIPTPATH%\sass.dart.snapshot" %arguments% diff --git a/package/dart-sass.bat b/package/dart-sass.bat index 4c4c00c3..4b0e584c 100644 --- a/package/dart-sass.bat +++ b/package/dart-sass.bat @@ -11,4 +11,4 @@ echo "WARNING: The dart-sass executable is deprecated, use sass instead." set SCRIPTPATH=%~dp0 set arguments=%* -"%SCRIPTPATH%\src\dart.exe" "-Dversion=SASS_VERSION" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments% +"%SCRIPTPATH%\src\dart.exe" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments% diff --git a/package/dart-sass.sh b/package/dart-sass.sh index fb07d8b2..fd787814 100644 --- a/package/dart-sass.sh +++ b/package/dart-sass.sh @@ -22,4 +22,4 @@ fi # Unlike $0, $BASH_SOURCE points to the absolute path of this file. path=`dirname "$(follow_links "$BASH_SOURCE")"` -exec "$path/src/dart" "-Dversion=SASS_VERSION" "$path/src/sass.dart.snapshot" "$@" +exec "$path/src/dart" "$path/src/sass.dart.snapshot" "$@" diff --git a/package/sass.bat b/package/sass.bat index 6f8ba025..2851f0bf 100644 --- a/package/sass.bat +++ b/package/sass.bat @@ -9,4 +9,4 @@ REM grinder package`. set SCRIPTPATH=%~dp0 set arguments=%* -"%SCRIPTPATH%\src\dart.exe" "-Dversion=SASS_VERSION" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments% +"%SCRIPTPATH%\src\dart.exe" "%SCRIPTPATH%\src\sass.dart.snapshot" %arguments% diff --git a/package/sass.sh b/package/sass.sh index 4a2812e8..42da5e46 100644 --- a/package/sass.sh +++ b/package/sass.sh @@ -18,4 +18,4 @@ follow_links() { # Unlike $0, $BASH_SOURCE points to the absolute path of this file. path=`dirname "$(follow_links "$0")"` -exec "$path/src/dart" "-Dversion=SASS_VERSION" "$path/src/sass.dart.snapshot" "$@" +exec "$path/src/dart" "$path/src/sass.dart.snapshot" "$@" diff --git a/pubspec.yaml b/pubspec.yaml index 9c31933d..e430936c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: sass -version: 1.24.2 +version: 1.24.3 description: A Sass implementation in Dart. author: Sass Team homepage: https://github.com/sass/dart-sass diff --git a/tool/grind/chocolatey.dart b/tool/grind/chocolatey.dart index ea2b1b3a..92d48754 100644 --- a/tool/grind/chocolatey.dart +++ b/tool/grind/chocolatey.dart @@ -32,8 +32,7 @@ void chocolateyPackage() { "package/chocolatey/chocolateyInstall.ps1")) ..addFile(file("tools/chocolateyUninstall.ps1", "package/chocolatey/chocolateyUninstall.ps1")) - ..addFile(fileFromString("tools/sass.bat", - readAndReplaceVersion("package/chocolatey/sass.bat"))); + ..addFile(file("tools/sass.bat", "package/chocolatey/sass.bat")); var output = "build/sass.${_chocolateyVersion()}.nupkg"; log("Creating $output..."); diff --git a/tool/grind/standalone.dart b/tool/grind/standalone.dart index cd10bead..70207fbf 100644 --- a/tool/grind/standalone.dart +++ b/tool/grind/standalone.dart @@ -18,7 +18,8 @@ bool get _is64Bit => Platform.version.contains("x64"); @Task('Build Dart script snapshot.') void snapshot() { ensureBuild(); - Dart.run('bin/sass.dart', vmArgs: ['--snapshot=build/sass.dart.snapshot']); + Dart.run('bin/sass.dart', + vmArgs: ['-Dversion=$version', '--snapshot=build/sass.dart.snapshot']); } @Task('Build a dev-mode Dart application snapshot.') @@ -42,6 +43,7 @@ void _appSnapshot() { arguments: ['tool/app-snapshot-input.scss'], vmArgs: [ '--enable-asserts', + '-Dversion=$version', '--snapshot=build/sass.dart.app.snapshot', '--snapshot-kind=app-jit' ], @@ -103,15 +105,11 @@ Future _buildPackage(String os) async { ..addFile(file("dart-sass/src/sass.dart.snapshot", useNative ? "build/sass.dart.native" : "build/sass.dart.snapshot")) ..addFile(file("dart-sass/src/SASS_LICENSE", "LICENSE")) - ..addFile(fileFromString( - "dart-sass/dart-sass${os == 'windows' ? '.bat' : ''}", - readAndReplaceVersion( - "package/dart-sass.${os == 'windows' ? 'bat' : 'sh'}"), + ..addFile(file("dart-sass/dart-sass${os == 'windows' ? '.bat' : ''}", + "package/dart-sass.${os == 'windows' ? 'bat' : 'sh'}", executable: true)) - ..addFile(fileFromString( - "dart-sass/sass${os == 'windows' ? '.bat' : ''}", - readAndReplaceVersion( - "package/sass.${os == 'windows' ? 'bat' : 'sh'}"), + ..addFile(file("dart-sass/sass${os == 'windows' ? '.bat' : ''}", + "package/sass.${os == 'windows' ? 'bat' : 'sh'}", executable: true)); var prefix = 'build/dart-sass-$version-$os-$architecture'; diff --git a/tool/grind/utils.dart b/tool/grind/utils.dart index 44eaf02a..8760e936 100644 --- a/tool/grind/utils.dart +++ b/tool/grind/utils.dart @@ -35,11 +35,6 @@ void ensureBuild() { Directory('build').createSync(recursive: true); } -/// Reads [file], replaces all instances of SASS_VERSION with the actual -/// version, and returns its contents. -String readAndReplaceVersion(String file) => - File(file).readAsStringSync().replaceAll("SASS_VERSION", version); - /// Returns the environment variable named [name], or throws an exception if it /// can't be found. String environment(String name) {