Skip to content

Commit

Permalink
Pass the version variable to script snapshots at build time
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3 committed Jan 7, 2020
1 parent bfdf4b3 commit c39a6b7
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 21 deletions.
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" "$@"
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

0 comments on commit c39a6b7

Please sign in to comment.