MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / formatFromFilename

Function formatFromFilename

src/lib/io-util.ts:15–25  ·  view source on GitHub ↗
(filename: string)

Source from the content-addressed store, hash-verified

13 | 'common' // Q&A or command line for input; table format for output
14
15export function formatFromFilename(filename: string): IOFormat {
16 const ext = path.extname(filename).toLowerCase()
17 if (ext === '.yaml' || ext === '.yml') {
18 return 'yaml'
19 }
20 if (ext === '.json') {
21 return 'json'
22 }
23 log4js.getLogger('cli').warn(`could not determine file type from filename "${filename}, assuming YAML`)
24 return 'yaml'
25}
26
27
28export function parseJSONOrYAML<T>(rawInputData: string, source: string): T {

Callers 3

calculateOutputFormatFunction · 0.85
fileInputProcessorFunction · 0.85
io-util.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected