resolve path in cli/log/config
This commit is contained in:
@@ -1,48 +1,17 @@
|
||||
#!/usr/bin/env node
|
||||
process.env.NODE_ENV = 'production'
|
||||
|
||||
const pkg = require('../package.json')
|
||||
const path = require('path')
|
||||
|
||||
const cwd = process.cwd()
|
||||
const data_path = process.env.GANCIO_DATA || path.resolve('./')
|
||||
process.env.cwd = path.resolve('./')
|
||||
|
||||
// needed by nuxt
|
||||
// process.chdir(path.resolve(__dirname, '..'))
|
||||
|
||||
// async function run_migrations (db_conf) {
|
||||
// const Umzug = require('umzug')
|
||||
// const Sequelize = require('sequelize')
|
||||
// try {
|
||||
// const db = new Sequelize(db_conf)
|
||||
// const umzug = new Umzug({
|
||||
// storage: 'sequelize',
|
||||
// storageOptions: { sequelize: db },
|
||||
// logging: consola.info,
|
||||
// migrations: {
|
||||
// wrap: fun => {
|
||||
// return () =>
|
||||
// fun(db.queryInterface, Sequelize).catch(e => {
|
||||
// consola.error(e)
|
||||
// return false
|
||||
// })
|
||||
// },
|
||||
// path: path.resolve(__dirname, 'migrations')
|
||||
// }
|
||||
// })
|
||||
// await umzug.up()
|
||||
// return db.close()
|
||||
// } catch (e) {
|
||||
// consola.warn(` ⚠️ Cannot connect to db, check your configuration => ${e}`)
|
||||
// process.exit(-1)
|
||||
// }
|
||||
// }
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
process.chdir(path.resolve(__dirname, '..'))
|
||||
}
|
||||
|
||||
async function start (options) {
|
||||
try {
|
||||
const config = require('./config')
|
||||
config.load()
|
||||
console.info(`Logging to ${path.resolve(`${config.log_path}/gancio.log`)} [level: ${config.log_level}]`)
|
||||
require('./config')
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
process.exit(-1)
|
||||
@@ -51,8 +20,7 @@ async function start (options) {
|
||||
require('./index')
|
||||
}
|
||||
|
||||
// async function setup (options)
|
||||
console.info(`📅 ${pkg.name} - v${pkg.version} - ${pkg.description} (nodejs: ${process.version})`)
|
||||
console.info(`📅 ${pkg.name} - v${pkg.version} - ${pkg.description} (nodejs: ${process.version}, ENV: ${process.env.NODE_ENV})`)
|
||||
|
||||
require('yargs')
|
||||
.usage('Usage $0 <command> [options]')
|
||||
@@ -62,16 +30,13 @@ require('yargs')
|
||||
default: false,
|
||||
type: 'boolean'
|
||||
})
|
||||
.option('db', {
|
||||
describe: 'Specify db type'
|
||||
})
|
||||
.option('config', {
|
||||
alias: 'c',
|
||||
describe: 'Configuration file',
|
||||
default: path.resolve(data_path, 'config.json')
|
||||
default: path.resolve(process.env.cwd, 'config.json')
|
||||
})
|
||||
.coerce('config', config_path => {
|
||||
const absolute_config_path = path.resolve(cwd, config_path)
|
||||
const absolute_config_path = path.resolve(process.env.cwd, config_path)
|
||||
process.env.config_path = absolute_config_path
|
||||
return absolute_config_path
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user