/
file.ts
36 lines (31 loc) · 935 Bytes
/
file.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
import { log } from 'ern-core'
import { getActiveCauldron } from 'ern-cauldron-api'
import {
epilog,
logErrorAndExitIfNotSatisfied,
tryCatchWrap,
} from '../../../lib'
import { Argv } from 'yargs'
import untildify from 'untildify'
export const command = 'file <localFilePath> <cauldronFilePath>'
export const desc = 'Add a file in the Cauldron'
export const builder = (argv: Argv) =>
argv.coerce('localFilePath', p => untildify(p)).epilog(epilog(exports))
export const commandHandler = async ({
cauldronFilePath,
localFilePath,
}: {
cauldronFilePath: string
localFilePath: string
}) => {
await logErrorAndExitIfNotSatisfied({
isFilePath: { p: localFilePath },
})
const cauldron = await getActiveCauldron()
await cauldron.addFile({
cauldronFilePath,
localFilePath,
})
log.info(`${localFilePath} file successfully added to the Cauldron`)
}
export const handler = tryCatchWrap(commandHandler)