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

Function yamlExists

src/lib/io-util.ts:77–99  ·  view source on GitHub ↗
(filepath: string)

Source from the content-addressed store, hash-verified

75 * Enforces official file extension and warns user if incorrect file detected.
76 */
77export function yamlExists(filepath: string): boolean {
78 const parsedPath = path.parse(filepath)
79
80 if (parsedPath.ext !== '.yaml') {
81 return fatalError(`Invalid file extension: ${parsedPath.ext}`)
82 }
83
84 if (!fs.existsSync(filepath)) {
85 const ymlPath = path.format({
86 dir: parsedPath.dir,
87 name: parsedPath.name,
88 ext: '.yml',
89 })
90
91 if (fs.existsSync(ymlPath)) {
92 console.error(`Ignoring ${ymlPath} and using default. Please use ".yaml" extension instead.`)
93 }
94
95 return false
96 }
97
98 return true
99}

Callers 3

loadLog4jsConfigFunction · 0.85
loadConfigFileFunction · 0.85
io-util.test.tsFile · 0.85

Calls 1

fatalErrorFunction · 0.85

Tested by

no test coverage detected