diff --git a/CHANGELOG.md b/CHANGELOG.md index 221d0c4..e9519ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 1.0.0-beta.2 + +* Fix a bug where the version variable wouldn't be set for certain executables. + # 1.0.0-beta.1 * Initial beta release. diff --git a/lib/src/chocolatey.dart b/lib/src/chocolatey.dart index 259c2fb..94a74d6 100644 --- a/lib/src/chocolatey.dart +++ b/lib/src/chocolatey.dart @@ -222,11 +222,8 @@ Future _build() async { archive.addFile(fileFromString( "tools/$name.bat", - renderTemplate("chocolatey/executable.bat", { - "name": _chocolateyName, - "version": version.toString(), - "executable": p.basename(path) - }), + renderTemplate("chocolatey/executable.bat", + {"name": _chocolateyName, "executable": p.basename(path)}), executable: true)); }); diff --git a/lib/src/standalone.dart b/lib/src/standalone.dart index 5c9a83d..f12f73c 100644 --- a/lib/src/standalone.dart +++ b/lib/src/standalone.dart @@ -41,8 +41,10 @@ void _compileSnapshot() { ensureBuild(); for (var entrypoint in entrypoints) { - Dart.run(entrypoint, - vmArgs: ['--snapshot=build/${p.basename(entrypoint)}.snapshot']); + Dart.run(entrypoint, vmArgs: [ + '-Dversion=$version', + '--snapshot=build/${p.basename(entrypoint)}.snapshot' + ]); } } @@ -149,11 +151,8 @@ Future _buildPackage(String os, {@required bool x64}) async { archive.addFile(fileFromString( "$standaloneName/$name${os == 'windows' ? '.bat' : ''}", renderTemplate( - "standalone/executable.${os == 'windows' ? 'bat' : 'sh'}", { - "name": standaloneName, - "version": _useNative(os, x64: x64) ? null : version.toString(), - "executable": p.basename(path) - }), + "standalone/executable.${os == 'windows' ? 'bat' : 'sh'}", + {"name": standaloneName, "executable": p.basename(path)}), executable: true)); }); diff --git a/lib/src/templates/chocolatey/executable.bat.mustache b/lib/src/templates/chocolatey/executable.bat.mustache index 3b539d3..41740e9 100644 --- a/lib/src/templates/chocolatey/executable.bat.mustache +++ b/lib/src/templates/chocolatey/executable.bat.mustache @@ -4,4 +4,4 @@ REM Dart executable and a snapshot of {{{name}}}. set SCRIPTPATH=%~dp0 set arguments=%* -dart.exe {{#version}}"-Dversion={{{version}}}"{{/version}} "%SCRIPTPATH%\{{{executable}}}.snapshot" %arguments% +dart.exe "%SCRIPTPATH%\{{{executable}}}.snapshot" %arguments% diff --git a/lib/src/templates/standalone/executable.bat.mustache b/lib/src/templates/standalone/executable.bat.mustache index df140f9..bb6cc62 100644 --- a/lib/src/templates/standalone/executable.bat.mustache +++ b/lib/src/templates/standalone/executable.bat.mustache @@ -4,4 +4,4 @@ REM Dart executable and a snapshot of {{{name}}}. set SCRIPTPATH=%~dp0 set arguments=%* -"%SCRIPTPATH%\src\dart.exe" {{#version}}"-Dversion={{{version}}}"{{/version}} "%SCRIPTPATH%\src\{{{executable}}}.snapshot" %arguments% +"%SCRIPTPATH%\src\dart.exe" "%SCRIPTPATH%\src\{{{executable}}}.snapshot" %arguments% diff --git a/lib/src/templates/standalone/executable.sh.mustache b/lib/src/templates/standalone/executable.sh.mustache index b77954a..a13a102 100644 --- a/lib/src/templates/standalone/executable.sh.mustache +++ b/lib/src/templates/standalone/executable.sh.mustache @@ -14,4 +14,4 @@ follow_links() { # Unlike $0, $BASH_SOURCE points to the absolute path of this file. path=`dirname "$(follow_links "$0")"` -exec "$path/src/dart" {{#version}}"-Dversion={{{version}}}"{{/version}} "$path/src/{{{executable}}}.snapshot" "$@" +exec "$path/src/dart" "$path/src/{{{executable}}}.snapshot" "$@" diff --git a/test/chocolatey_test.dart b/test/chocolatey_test.dart index c06143c..ba17491 100644 --- a/test/chocolatey_test.dart +++ b/test/chocolatey_test.dart @@ -357,7 +357,7 @@ void main() { var executable = await TestProcess.start(d.path("out/tools/foo.bat"), [], workingDirectory: d.sandbox); - expect(executable.stdout, emits("in foo")); + expect(executable.stdout, emits("in foo 1.2.3")); await executable.shouldExit(0); }, testOn: "windows"); }); diff --git a/test/descriptor.dart b/test/descriptor.dart index 8604936..234c851 100644 --- a/test/descriptor.dart +++ b/test/descriptor.dart @@ -66,7 +66,12 @@ DirectoryDescriptor package(Map pubspec, String grindDotDart, dir("bin", [ for (var basename in executables) - file("$basename.dart", 'void main() => print("in $basename");') + file( + "$basename.dart", + // Include the version variable to ensure that executables we invoke + // have access to it. + 'void main() => print("in $basename ' + '\${const String.fromEnvironment("version")}");') ]), dir("tool", [ diff --git a/test/npm_test.dart b/test/npm_test.dart index b9a1047..50cdd85 100644 --- a/test/npm_test.dart +++ b/test/npm_test.dart @@ -172,17 +172,17 @@ void main() { var process = await TestProcess.start( "node$dotExe", [d.path("my_app/build/npm/foo.js")]); - expect(process.stdout, emitsInOrder(["in foo", emitsDone])); + expect(process.stdout, emitsInOrder(["in foo 1.2.3", emitsDone])); await process.shouldExit(0); process = await TestProcess.start( "node$dotExe", [d.path("my_app/build/npm/bar.js")]); - expect(process.stdout, emitsInOrder(["in bar", emitsDone])); + expect(process.stdout, emitsInOrder(["in bar 1.2.3", emitsDone])); await process.shouldExit(0); process = await TestProcess.start( "node$dotExe", [d.path("my_app/build/npm/qux.js")]); - expect(process.stdout, emitsInOrder(["in zang", emitsDone])); + expect(process.stdout, emitsInOrder(["in zang 1.2.3", emitsDone])); await process.shouldExit(0); }); diff --git a/test/standalone_test.dart b/test/standalone_test.dart index 6dc8306..faddbbb 100644 --- a/test/standalone_test.dart +++ b/test/standalone_test.dart @@ -177,34 +177,34 @@ void main() { var executable = await TestProcess.start( d.path("out/my_app/foo$dotBat"), [], workingDirectory: d.sandbox); - expect(executable.stdout, emits("in foo")); + expect(executable.stdout, emits("in foo 1.2.3")); await executable.shouldExit(0); // Through a redirect executable = await TestProcess.start(d.path("out/my_app/qux$dotBat"), [], workingDirectory: d.sandbox); - expect(executable.stdout, emits("in bar")); + expect(executable.stdout, emits("in bar 1.2.3")); await executable.shouldExit(0); // Through a relative symlink Link(d.path("foo-relative")).createSync("out/my_app/foo$dotBat"); executable = await TestProcess.start(d.path("foo-relative"), [], workingDirectory: d.sandbox); - expect(executable.stdout, emits("in foo")); + expect(executable.stdout, emits("in foo 1.2.3")); await executable.shouldExit(0); // Through an absolute symlink Link(d.path("foo-absolute")).createSync(d.path("out/my_app/foo$dotBat")); executable = await TestProcess.start(d.path("foo-absolute"), [], workingDirectory: d.sandbox); - expect(executable.stdout, emits("in foo")); + expect(executable.stdout, emits("in foo 1.2.3")); await executable.shouldExit(0); // Through a nested symlink Link(d.path("foo-nested")).createSync(d.path("foo-relative")); executable = await TestProcess.start(d.path("foo-nested"), [], workingDirectory: d.sandbox); - expect(executable.stdout, emits("in foo")); + expect(executable.stdout, emits("in foo 1.2.3")); await executable.shouldExit(0); }, onPlatform: {"windows": Skip("google/dart_cli_pkg#25")}); }, onPlatform: {if (!useDart2Native) "windows": Skip("dart-lang/sdk#37897")});