File tree 1 file changed +5
-6
lines changed
1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change 1
1
import { existsSync } from 'fs'
2
2
import { readFile , writeFile } from 'fs/promises'
3
3
import { resolve } from 'path'
4
- import { CliOptions } from './options'
5
4
6
- export interface AlbumOptions extends Partial < CliOptions > {
5
+ export interface AlbumOptions {
7
6
defaultAlbumHint ?: string
8
7
}
9
8
10
9
const AlbumOptionsFileName = 'thtag.json'
11
10
export const getAlbumOptions = async (
12
11
workingDir : string ,
13
- baseOptions : Partial < CliOptions > = { } ,
12
+ fallback : Partial < AlbumOptions > = { } ,
14
13
) : Promise < AlbumOptions > => {
15
14
const albumOptionsPath = resolve ( workingDir , AlbumOptionsFileName )
16
15
if ( ! existsSync ( albumOptionsPath ) ) {
17
- return baseOptions
16
+ return fallback
18
17
}
19
18
try {
20
19
const albumOptions = JSON . parse (
21
20
await readFile ( albumOptionsPath , { encoding : 'utf-8' } ) ,
22
21
) as AlbumOptions
23
22
return {
24
- ...baseOptions ,
23
+ ...fallback ,
25
24
...albumOptions ,
26
25
}
27
26
} catch ( error ) {
28
- return baseOptions
27
+ return fallback
29
28
}
30
29
}
31
30
export const setAlbumOptions = async ( workingDir : string , options : Partial < AlbumOptions > ) => {
You can’t perform that action at this time.
0 commit comments