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:
parent
d4ddf4a3e3
commit
c84413517f
2 changed files with 9 additions and 4 deletions
11
bin/sinopia
11
bin/sinopia
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue