mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-02-17 23:45:29 -05:00
fix crash when using sinopia as a library
This commit is contained in:
parent
4a46ffe3a0
commit
6ec76aa61f
2 changed files with 5 additions and 1 deletions
|
@ -72,7 +72,6 @@ function get_hostport() {
|
|||
}
|
||||
|
||||
function afterConfigLoad() {
|
||||
if (!config.user_agent) config.user_agent = 'Sinopia/'+pkg.version
|
||||
if (!config.self_path) config.self_path = Path.resolve(config_path)
|
||||
|
||||
var hostport = get_hostport()
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
var assert = require('assert')
|
||||
var Crypto = require('crypto')
|
||||
var fs = require('fs')
|
||||
var YAML = require('js-yaml')
|
||||
var Error = require('http-errors')
|
||||
var minimatch = require('minimatch')
|
||||
var Path = require('path')
|
||||
var LocalData = require('./local-data')
|
||||
var Utils = require('./utils')
|
||||
var pkg_file = '../package.yaml'
|
||||
var pkg = YAML.safeLoad(fs.readFileSync(__dirname+'/'+pkg_file, 'utf8'))
|
||||
|
||||
// [[a, [b, c]], d] -> [a, b, c, d]
|
||||
function flatten(array) {
|
||||
|
@ -24,6 +28,7 @@ function Config(config) {
|
|||
for (var i in config) {
|
||||
if (self[i] == null) self[i] = config[i]
|
||||
}
|
||||
if (!self.user_agent) self.user_agent = 'Sinopia/'+pkg.version
|
||||
|
||||
// some weird shell scripts are valid yaml files parsed as string
|
||||
assert.equal(typeof(config), 'object', 'CONFIG: it doesn\'t look like a valid config file')
|
||||
|
|
Loading…
Add table
Reference in a new issue