mirror of
https://github.com/status-im/codimd.git
synced 2025-01-12 18:34:30 +00:00
ts: lib/config/utils.js
Signed-off-by: Raccoon <raccoon@hackmd.io>
This commit is contained in:
parent
2a376db0fc
commit
294283f64f
@ -1,30 +1,28 @@
|
||||
'use strict'
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
|
||||
exports.toBooleanConfig = function toBooleanConfig (configValue) {
|
||||
export function toBooleanConfig(configValue) {
|
||||
if (configValue && typeof configValue === 'string') {
|
||||
return (configValue === 'true')
|
||||
}
|
||||
return configValue
|
||||
}
|
||||
|
||||
exports.toArrayConfig = function toArrayConfig (configValue, separator = ',', fallback) {
|
||||
export function toArrayConfig(configValue, separator = ',', fallback) {
|
||||
if (configValue && typeof configValue === 'string') {
|
||||
return (configValue.split(separator).map(arrayItem => arrayItem.trim()))
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
exports.toIntegerConfig = function toIntegerConfig (configValue) {
|
||||
export function toIntegerConfig(configValue) {
|
||||
if (configValue && typeof configValue === 'string') {
|
||||
return parseInt(configValue)
|
||||
}
|
||||
return configValue
|
||||
}
|
||||
|
||||
exports.getGitCommit = function getGitCommit (repodir) {
|
||||
export function getGitCommit(repodir) {
|
||||
if (!fs.existsSync(repodir + '/.git/HEAD')) {
|
||||
return undefined
|
||||
}
|
||||
@ -37,7 +35,7 @@ exports.getGitCommit = function getGitCommit (repodir) {
|
||||
return reference
|
||||
}
|
||||
|
||||
exports.getGitHubURL = function getGitHubURL (repo, reference) {
|
||||
export function getGitHubURL(repo, reference) {
|
||||
// if it's not a github reference, we handle handle that anyway
|
||||
if (!repo.startsWith('https://github.com') && !repo.startsWith('git@github.com')) {
|
||||
return repo
|
Loading…
x
Reference in New Issue
Block a user