1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

accept requestJson for create/edit as stdin

This commit is contained in:
Kyle Spearrin
2018-05-16 22:40:48 -04:00
parent 9cce555899
commit 07cb4d5ff8
5 changed files with 66 additions and 33 deletions

View File

@@ -3,6 +3,32 @@ import { CollectionView } from 'jslib/models/view/collectionView';
import { FolderView } from 'jslib/models/view/folderView';
export class CliUtils {
static readStdin(): Promise<string> {
return new Promise((resolve, reject) => {
let input: string = '';
if (process.stdin.isTTY) {
resolve(input);
return;
}
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
while (true) {
const chunk = process.stdin.read();
if (chunk == null) {
break;
}
input += chunk;
}
});
process.stdin.on('end', () => {
resolve(input);
});
});
}
static searchCiphers(ciphers: CipherView[], search: string) {
search = search.toLowerCase();
return ciphers.filter((c) => {