Skip to content

Commit

Permalink
Merge pull request #5 from dnys1/chore/interhit-io
Browse files Browse the repository at this point in the history
chore: Inherit stdio
  • Loading branch information
salihgueler authored Aug 4, 2022
2 parents 43bfee8 + 4f990d5 commit ed3cded
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions hooks/post_gen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,18 @@ Future<void> _runAmplifyInit(HookContext context) async {
'amplify',
['init', '--yes'],
workingDirectory: '{{project_name}}',
mode: ProcessStartMode.inheritStdio,
);

// Complete progress so it doesn't interfere with stdout of `amplify`
amplifyInitProgress.complete();

final exitCode = await result.exitCode;

if (exitCode == 0) {
amplifyInitProgress.complete('Project is initialized.');
context.logger.success('Project is initialized.');
} else {
final errorBytes = await result.stderr.first;
final error = systemEncoding.decode(errorBytes);
amplifyInitProgress.complete('Project initialization failed. $error');
context.logger.err('Project initialization failed.');
exit(exitCode);
}
}
Expand Down Expand Up @@ -166,20 +168,21 @@ Future<void> _runAmplifyPush(HookContext context, String input) async {
'running "amplify push"',
);

final result = Process.runSync(
final result = await Process.start(
'amplify',
['push', '--yes'],
workingDirectory: '{{project_name}}',
mode: ProcessStartMode.inheritStdio,
);

amplifyPushProgress.complete();

final exitCode = await result.exitCode;

if (exitCode == 0) {
amplifyPushProgress.complete('Backend is pushed');
context.logger.success('Backend is pushed');
} else {
final errorBytes = await result.stderr.first;
final error = systemEncoding.decode(errorBytes);
amplifyPushProgress.complete('Backend push is failed. $error');
context.logger.err('Backend push failed.');
exit(exitCode);
}
} else {
Expand Down

0 comments on commit ed3cded

Please sign in to comment.