- use different pen for write logs

- remove default value for configuration, to cleanly fallback to defaults
- rename gitHelper, move dir exists helper
- add reading input values group
- improve warning for configuration
This commit is contained in:
Mike Penz
2020-10-17 19:37:11 +02:00
parent 1e0f6ab49e
commit bd49950417
7 changed files with 78 additions and 76 deletions
+31
View File
@@ -10,3 +10,34 @@ export function readConfiguration(filename: string): Configuration | null {
return null
}
}
export function directoryExistsSync(path: string, required?: boolean): boolean {
if (!path) {
throw new Error("Arg 'path' must not be empty")
}
let stats: fs.Stats
try {
stats = fs.statSync(path)
} catch (error) {
if (error.code === 'ENOENT') {
if (!required) {
return false
}
throw new Error(`Directory '${path}' does not exist`)
}
throw new Error(
`Encountered an error when checking whether path '${path}' exists: ${error.message}`
)
}
if (stats.isDirectory()) {
return true
} else if (!required) {
return false
}
throw new Error(`Directory '${path}' does not exist`)
}