Skip to content

Commit

Permalink
fix: move to local storage the fs location handler
Browse files Browse the repository at this point in the history
  • Loading branch information
@jotadeveloper authored and sergiohgz committed Aug 13, 2019
1 parent 9f0ba84 commit 3b12083
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
2 changes: 1 addition & 1 deletion plugins/local-storage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"mkdirp": "0.5.1"
},
"devDependencies": {
"@verdaccio/types": "0.1.0",
"@verdaccio/types": "^0.1.1",
"babel-cli": "6.24.1",
"babel-core": "6.25.0",
"babel-eslint": "7.2.3",
Expand Down
25 changes: 23 additions & 2 deletions plugins/local-storage/src/local-database.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Path from 'path';
import LocalFS from './local-fs';
import mkdirp from 'mkdirp';
import type {StorageList, LocalStorage, Logger, Config} from '@verdaccio/types';
import type {ILocalPackageManager, ILocalData} from '@verdaccio/local-storage';
import type {IPackageStorage, ILocalData} from '@verdaccio/local-storage';

/**
* Handle local database.
Expand Down Expand Up @@ -91,14 +91,35 @@ import type {ILocalPackageManager, ILocalData} from '@verdaccio/local-storage';
}
}

getPackageStorage(packageInfo: string, packagePath: string): ILocalPackageManager {
getPackageStorage(packageInfo: string): IPackageStorage {
const packagePath: string = this._getLocalStoragePath(this.config.getMatchedPackagesSpec(packageInfo).storage);

if (_.isString(packagePath) === false) {
this.logger.debug( {name: packageInfo}, 'this package has no storage defined: @{name}' );
return;
}

const packageStoragePath: string = Path.join(
Path.resolve(Path.dirname(this.config.self_path || ''), packagePath),
packageInfo);

return new LocalFS(packageStoragePath, this.logger);
}

/**
* Verify the right local storage location.
* @param {String} path
* @return {String}
* @private
*/
_getLocalStoragePath(path: string): string {
if (_.isNil(path) === false) {
return path;
}

return this.config.storage;
}

/**
* Build the local database path.
* @param {Object} config
Expand Down
6 changes: 3 additions & 3 deletions plugins/local-storage/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
version "0.0.2"
resolved "https://registry.npmjs.org/@verdaccio/streams/-/streams-0.0.2.tgz#72cd65449e657b462a1ca094f663cad9ea872427"

"@verdaccio/[email protected].0":
version "0.1.0"
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-0.1.0.tgz#2a0a6066bbbb7841d29298463e761147fb1f7f00"
"@verdaccio/types@^0.1.1":
version "0.1.1"
resolved "https://registry.npmjs.org/@verdaccio/types/-/types-0.1.1.tgz#0801494fbd0284f6e92d94c85b90d97ba9dfa1c8"

abab@^1.0.3:
version "1.0.4"
Expand Down

0 comments on commit 3b12083

Please sign in to comment.