From d4d55d6a8f5fa3ba7c9b3fc2b604cf1c0f19d675 Mon Sep 17 00:00:00 2001 From: thosakwe Date: Fri, 23 Dec 2016 23:45:37 -0500 Subject: [PATCH] 13 --- lib/src/commands/key.dart | 11 ++++++++--- pubspec.yaml | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/src/commands/key.dart b/lib/src/commands/key.dart index 5f311e33..41524e8e 100644 --- a/lib/src/commands/key.dart +++ b/lib/src/commands/key.dart @@ -20,18 +20,23 @@ class KeyCommand extends Command { changeSecret(File file, String secret) async { if (await file.exists()) { + bool foundSecret = false; var sink = await file.openWrite(); - await for (var chunk - in await file.openRead().transform(UTF8.decoder)) { + await for (var chunk in await file.openRead().transform(UTF8.decoder)) { var lines = chunk.split('\n'); for (String line in lines) { if (line.contains('jwt_secret:')) { + foundSecret = true; sink.writeln('jwt_secret: $secret'); - } else sink.writeln(line); + } else + sink.writeln(line); } } + + if (!foundSecret) sink.writeln('jwt:secret: $secret'); + await sink.close(); } } } diff --git a/pubspec.yaml b/pubspec.yaml index 78bbc2db..78527b67 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_cli -version: 1.0.0-dev+12 +version: 1.0.0-dev+13 description: Command-line tools for the Angel framework. environment: sdk: ">=1.19.0"