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

FEDX-518 Now that dart_dev itself is null-safe, it should be able to generate a null-safe run script #420

Merged
merged 2 commits into from
Nov 9, 2023
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,5 +1,10 @@
# Changelog

## 4.0.3

- Fix generation of the run script that the `dart_dev` CLI uses so that it can
run with sound null safety (and thus run on Dart 3).

## 4.0.1

- Fix type mismatch between the expected return type of the function passed to
Expand Down
8 changes: 0 additions & 8 deletions lib/src/executable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,13 @@ bool get shouldWriteRunScript =>
!_runScript.existsSync() ||
_runScript.readAsStringSync() != buildDartDevRunScriptContents();

/// Whether dart_dev itself has opted into null-safety.
const _isDartDevNullSafe = false;

String buildDartDevRunScriptContents() {
final hasCustomToolDevDart = File(paths.config).existsSync();
// If the config has a dart version comment (e.g., if it opts out of null safety),
// copy it over to the entrypoint so the program is run in that language version.
var dartVersionComment = hasCustomToolDevDart
? getDartVersionComment(File(paths.config).readAsStringSync())
: null;
// If dart_dev itself is not null-safe, opt the entrypoint out of null-safety
// so the entrypoint doesn't fail to run in packages that have opted into null-safety.
if (!_isDartDevNullSafe && dartVersionComment == null) {
dartVersionComment = '// @dart=2.9';
}

return '''
${dartVersionComment ?? ''}
Expand Down