mirror of
https://github.com/verdaccio/verdaccio.git
synced 2024-12-16 21:56:25 -05:00
fix: don’t packages that have no uplinks after reading (#1204)
This commit is contained in:
parent
23b02c01fc
commit
95686be47d
2 changed files with 27 additions and 5 deletions
|
@ -487,7 +487,9 @@ class Storage implements IStorageHandler {
|
|||
, null
|
||||
, upLinksErrors );
|
||||
}
|
||||
|
||||
if (upLinks.length === 0) {
|
||||
return callback(null, packageInfo);
|
||||
}
|
||||
self.localStorage.updateVersions(name, packageInfo, function(err, packageJsonLocal: Package) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
import _ from 'lodash';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import rimraf from 'rimraf';
|
||||
// $FlowFixMe
|
||||
import configExample from '../partials/config/index';
|
||||
import AppConfig from '../../../src/lib/config';
|
||||
|
@ -16,12 +18,12 @@ import {DOMAIN_SERVERS} from '../../functional/config.functional';
|
|||
|
||||
setup(configExample.logs);
|
||||
|
||||
const storagePath = path.join(__dirname, '../partials/store/test-storage-store.spec');
|
||||
const mockServerPort: number = 55548;
|
||||
const generateStorage = async function(port = mockServerPort, configDefault = configExample) {
|
||||
const storageConfig = _.clone(configDefault);
|
||||
const storage = path.join(__dirname, '../partials/store/test-storage-store.spec');
|
||||
storageConfig.self_path = __dirname;
|
||||
storageConfig.storage = storage;
|
||||
storageConfig.storage = storagePath;
|
||||
storageConfig.uplinks = {
|
||||
npmjs: {
|
||||
url: `http://${DOMAIN_SERVERS}:${port}`
|
||||
|
@ -37,8 +39,11 @@ const generateStorage = async function(port = mockServerPort, configDefault = co
|
|||
describe('StorageTest', () => {
|
||||
let mockRegistry;
|
||||
|
||||
beforeAll(async () => {
|
||||
mockRegistry = await mockServer(mockServerPort).init();
|
||||
beforeAll(done => {
|
||||
rimraf(storagePath, async () => {
|
||||
mockRegistry = await mockServer(mockServerPort).init();
|
||||
done()
|
||||
})
|
||||
});
|
||||
|
||||
afterAll(function(done) {
|
||||
|
@ -90,5 +95,20 @@ describe('StorageTest', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('should not touch if the package exists and has no uplinks', async (done) => {
|
||||
const storage: IStorageHandler = await generateStorage();
|
||||
const metadataPath = path.join(storagePath, 'npm_test/package.json')
|
||||
fs.mkdirSync(path.join(storagePath, 'npm_test'))
|
||||
fs.copyFileSync(path.join(__dirname, '../partials/metadata'), metadataPath)
|
||||
const metadata = JSON.parse(fs.readFileSync(metadataPath).toString())
|
||||
const prevStat = fs.statSync(metadataPath)
|
||||
storage._syncUplinksMetadata('npm_test', metadata, {}, (err) => {
|
||||
expect(err).toBeFalsy()
|
||||
const nextStat = fs.statSync(metadataPath)
|
||||
expect(nextStat).toEqual(prevStat)
|
||||
done()
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue