aboutsummaryrefslogblamecommitdiffhomepage
path: root/server/tools/cli.ts
blob: 87d1512a3b8fdc394b4075a350b395dbe8727d71 (plain) (tree)
1
2
3
4
5

                                                            
                                             
 
                          
















































                                                                              
const config = require('application-config')('PeerTube/CLI')
const netrc = require('netrc-parser').default
import { getVersion } from '../helpers/utils'

const version = getVersion

let settings = {
  remotes: [],
  default: 0
}

interface Settings {
  remotes: any[],
  default: number
}

async function getSettings () {
  return new Promise<Settings>((res, rej) => {
    let settings = {
      remotes: [],
      default: 0
    } as Settings
    config.read((err, data) => {
      if (err) {
        return rej(err)
      }
      return res(data || settings)
    })
  })
}

async function writeSettings (settings) {
  return new Promise((res, rej) => {
    config.write(settings, function (err) {
      if (err) {
        return rej(err)
      }
      return res()
    })
  })
}

netrc.loadSync()

// ---------------------------------------------------------------------------

export {
  version,
  config,
  settings,
  getSettings,
  writeSettings,
  netrc
}