Skip to content

Commit 30240c7

Browse files
authored
Update lib.js
1 parent a1916ba commit 30240c7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

lib.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ var db = (sdb) => {
5656

5757
export default {
5858

59+
sh: async(first){
60+
var cmd = first instanceof Array ? first[0] : first;
61+
var p = Bun.spawn(["sh", "-c", cmd], {
62+
stdin: null,
63+
stdout: "pipe",
64+
stderr: "pipe",
65+
});
66+
var i = await p.exited
67+
if (i != 0) {
68+
throw `${cmd}: ${await Bun.readableStreamToText(p.stderr)}`;
69+
}
70+
return await Bun.readableStreamToText(p.stdout);
71+
},
72+
5973
video_second: async function(vora) {
6074
var a = await $`ffprobe -i ${vora} -show_entries format=duration -v quiet -of csv="p=0"`.text()
6175
return parseInt(parseFloat(a));

0 commit comments

Comments
 (0)