Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass the version variable to script snapshots at build time #920

Merged
merged 2 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package/chocolatey/sass.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%
2 changes: 1 addition & 1 deletion package/dart-sass.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%
2 changes: 1 addition & 1 deletion package/dart-sass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@"
2 changes: 1 addition & 1 deletion package/sass.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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%
2 changes: 1 addition & 1 deletion package/sass.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" "$@"
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 1 addition & 2 deletions tool/grind/chocolatey.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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...");
Expand Down
16 changes: 7 additions & 9 deletions tool/grind/standalone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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.')
Expand All @@ -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'
],
Expand Down Expand Up @@ -103,15 +105,11 @@ Future<void> _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';
Expand Down
5 changes: 0 additions & 5 deletions tool/grind/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down