Skip to content

Commit

Permalink
fix(mason): nested hooks execution (#1334)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored May 29, 2024
1 parent 6715910 commit 30dcf89
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions packages/mason/lib/src/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,13 @@ import 'package:pool/pool.dart';

part 'hooks.dart';

const bool _isAotCompiled = bool.fromEnvironment('dart.vm.product');
const bool _isProductMode = bool.fromEnvironment('dart.vm.product');
const _hookIsolateName = '__mason_hook__';
bool get _isHookIsolate => Isolate.current.debugName == _hookIsolateName;
bool get _useAot {
if (_isHookIsolate) return false;
return _isProductMode;
}

final _descriptorPool = Pool(32);
final _partialRegExp = RegExp(r'\{\{~\s(.+)\s\}\}');
Expand Down Expand Up @@ -641,7 +647,7 @@ extension on HookFile {
}

File module(String checksum) {
const extension = _isAotCompiled ? 'aot' : 'dill';
final extension = _useAot ? 'aot' : 'dill';
return File(
p.join(
buildDirectory.path,
Expand Down
4 changes: 2 additions & 2 deletions packages/mason/lib/src/hooks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ class GeneratorHooks {
final uri = await _getHookUri(hook, checksum);

if (uri == null) throw HookMissingRunException(hook.path);

const mode = _isAotCompiled ? 'aot-snapshot' : 'kernel';
final mode = _useAot ? 'aot-snapshot' : 'kernel';
final progress = logger?.progress('Compiling ${p.basename(hook.path)}');
final result = await Process.run(
'dart',
Expand Down Expand Up @@ -315,6 +314,7 @@ class GeneratorHooks {
[json.encode(vars)],
messagePort.sendPort,
paused: true,
debugName: _hookIsolateName,
);
}

Expand Down

0 comments on commit 30dcf89

Please sign in to comment.