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 {
|
changeSecret(File file, String secret) async {
|
||||||
if (await file.exists()) {
|
if (await file.exists()) {
|
||||||
bool foundSecret = false;
|
var contents = await file.readAsString();
|
||||||
var sink = await file.openWrite(mode: FileMode.APPEND);
|
contents = contents.replaceAll(new RegExp(r'jwt_secret:[^\n]+\n?'), '');
|
||||||
|
await file.writeAsString(contents.trim() + '\njwt_secret: $secret');
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_cli
|
name: angel_cli
|
||||||
version: 1.0.0-dev+14
|
version: 1.0.0-dev+15
|
||||||
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"
|
||||||
|
|
Loading…
Reference in a new issue