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:
26
src/utils.ts
26
src/utils.ts
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user