generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathexif.ts
41 lines (33 loc) · 834 Bytes
/
exif.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {exec, ExecOptions} from '@actions/exec'
export enum Tag {
Software = 'Software',
XMPToolkit = 'xmptoolkit'
}
export default class Exif {
private static COMMAND = '/usr/local/bin/exiftool'
constructor(private filename: string) {}
async get(tags: Tag[] = []): Promise<string> {
let output = ''
const options: ExecOptions = {
listeners: {
stdout(data: Buffer) {
output += data.toString()
}
}
}
await exec(
Exif.COMMAND,
['-veryShort', '-tab', ...tags.map(tag => `-${tag}`), this.filename],
options
)
return output
}
async set(inputs: [Tag, string][]): Promise<boolean> {
return Boolean(
await exec(Exif.COMMAND, [
...inputs.map(input => `-${input[0]}=${input[1]}`),
this.filename
])
)
}
}