Skip to content

Commit

Permalink
Merge pull request #420 from Workiva/generate-null-safe-run-script
Browse files Browse the repository at this point in the history
FEDX-518 Now that dart_dev itself is null-safe, it should be able to generate a null-safe run script
  • Loading branch information
rm-astro-wf authored Nov 9, 2023
2 parents 2d2f270 + 28b3bee commit 8903a9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
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

0 comments on commit 8903a9c

Please sign in to comment.