Key done
This commit is contained in:
parent
8d3329eb0a
commit
f9554a176d
2 changed files with 4 additions and 18 deletions
|
@ -20,23 +20,9 @@ class KeyCommand extends Command {
|
|||
|
||||
changeSecret(File file, String secret) async {
|
||||
if (await file.exists()) {
|
||||
bool foundSecret = false;
|
||||
var sink = await file.openWrite(mode: FileMode.APPEND);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundSecret) sink.writeln('jwt:secret: $secret');
|
||||
await sink.close();
|
||||
var contents = await file.readAsString();
|
||||
contents = contents.replaceAll(new RegExp(r'jwt_secret:[^\n]+\n?'), '');
|
||||
await file.writeAsString(contents.trim() + '\njwt_secret: $secret');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_cli
|
||||
version: 1.0.0-dev+14
|
||||
version: 1.0.0-dev+15
|
||||
description: Command-line tools for the Angel framework.
|
||||
environment:
|
||||
sdk: ">=1.19.0"
|
||||
|
|
Loading…
Reference in a new issue