This commit is contained in:
thosakwe 2016-12-23 23:45:37 -05:00
parent 6b36b314b7
commit d4d55d6a8f
2 changed files with 9 additions and 4 deletions

View file

@ -20,18 +20,23 @@ class KeyCommand extends Command {
changeSecret(File file, String secret) async { changeSecret(File file, String secret) async {
if (await file.exists()) { if (await file.exists()) {
bool foundSecret = false;
var sink = await file.openWrite(); var sink = await file.openWrite();
await for (var chunk await for (var chunk in await file.openRead().transform(UTF8.decoder)) {
in await file.openRead().transform(UTF8.decoder)) {
var lines = chunk.split('\n'); var lines = chunk.split('\n');
for (String line in lines) { for (String line in lines) {
if (line.contains('jwt_secret:')) { if (line.contains('jwt_secret:')) {
foundSecret = true;
sink.writeln('jwt_secret: $secret'); sink.writeln('jwt_secret: $secret');
} else sink.writeln(line); } else
sink.writeln(line);
} }
} }
if (!foundSecret) sink.writeln('jwt:secret: $secret');
await sink.close();
} }
} }
} }

View file

@ -1,5 +1,5 @@
name: angel_cli name: angel_cli
version: 1.0.0-dev+12 version: 1.0.0-dev+13
description: Command-line tools for the Angel framework. description: Command-line tools for the Angel framework.
environment: environment:
sdk: ">=1.19.0" sdk: ">=1.19.0"