0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-16 21:56:25 -05:00

making storage path relative to config path

This commit is contained in:
Alex Kocharin 2013-09-24 08:15:13 +04:00
parent d4ddf4a3e3
commit c84413517f
2 changed files with 9 additions and 4 deletions

View file

@ -14,21 +14,24 @@ commander
.version(pkg.version)
.parse(process.argv);
var config;
var config, config_path;
if (commander.config) {
config = yaml.safeLoad(fs.readFileSync(commander.config, 'utf8'));
config_path = commander.config;
config = yaml.safeLoad(fs.readFileSync(config_path, 'utf8'));
} else {
config_path = './config.yaml';
try {
config = yaml.safeLoad(fs.readFileSync('./config.yaml', 'utf8'));
config = yaml.safeLoad(fs.readFileSync(config_path, 'utf8'));
} catch(err) {
var created_config = require('../lib/config_gen')();
config = yaml.safeLoad(created_config.yaml);
console.log('starting with default config, use user: "%s", pass: "%s" to authenticate', created_config.user, created_config.pass);
fs.writeFileSync('./config.yaml', created_config.yaml);
fs.writeFileSync(config_path, created_config.yaml);
}
}
if (!config.user_agent) config.user_agent = 'Sinopia/'+pkg.version;
if (!config.self_path) config.self_path = config_path;
var hostport = commander.listen.split(':');
if (hostport.length < 2) {

View file

@ -1,6 +1,7 @@
var fs = require('fs');
var semver = require('semver');
var through = require('through');
var Path = require('path');
var fs_storage = require('./fs-storage');
var UError = require('./error').UserError;
var utils = require('./utils');
@ -9,6 +10,7 @@ var info_file = 'package.json';
function Storage(config) {
if (!(this instanceof Storage)) return new Storage(config);
this.config = config;
var path = Path.resolve(Path.dirname(this.config.self_path), this.config.storage);
this.storage = new fs_storage(this.config.storage);
return this;
}