mirror of
https://github.com/verdaccio/verdaccio.git
synced 2025-01-20 22:52:46 -05:00
fix: don’t make change if time
fields match (#1167)
This commit is contained in:
parent
23b02c01fc
commit
e62ef8df99
3 changed files with 27 additions and 6 deletions
|
@ -185,7 +185,7 @@ class LocalStorage implements IStorage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ('time' in packageInfo) {
|
if ('time' in packageInfo && !_.isEqual(packageLocalJson.time, packageInfo.time)) {
|
||||||
packageLocalJson.time = packageInfo.time;
|
packageLocalJson.time = packageInfo.time;
|
||||||
change = true;
|
change = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import rimRaf from 'rimraf';
|
import rimRaf from 'rimraf';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
import fs from 'fs';
|
||||||
import LocalStorage from '../../../src/lib/local-storage';
|
import LocalStorage from '../../../src/lib/local-storage';
|
||||||
import AppConfig from '../../../src/lib/config';
|
import AppConfig from '../../../src/lib/config';
|
||||||
// $FlowFixMe
|
// $FlowFixMe
|
||||||
|
@ -250,14 +251,16 @@ describe('LocalStorage', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('LocalStorage::updateVersions', () => {
|
describe('LocalStorage::updateVersions', () => {
|
||||||
test('should update versions from external source', async (done) => {
|
const metadata = JSON.parse(readMetadata('metadata-update-versions-tags'));
|
||||||
const metadata = JSON.parse(readMetadata('metadata-update-versions-tags'));
|
const pkgName = 'add-update-versions-test-1';
|
||||||
const pkgName = 'add-update-versions-test-1';
|
const version = '1.0.2';
|
||||||
const version = '1.0.2';
|
beforeAll(async () => {
|
||||||
await addPackageToStore(pkgName, generatePackageTemplate(pkgName));
|
await addPackageToStore(pkgName, generatePackageTemplate(pkgName));
|
||||||
await addNewVersion(pkgName, '1.0.1');
|
await addNewVersion(pkgName, '1.0.1');
|
||||||
await addNewVersion(pkgName, version);
|
await addNewVersion(pkgName, version);
|
||||||
|
})
|
||||||
|
|
||||||
|
test('should update versions from external source', async (done) => {
|
||||||
storage.updateVersions(pkgName, metadata, (err, data) => {
|
storage.updateVersions(pkgName, metadata, (err, data) => {
|
||||||
expect(err).toBeNull();
|
expect(err).toBeNull();
|
||||||
expect(data.versions['1.0.1']).toBeDefined();
|
expect(data.versions['1.0.1']).toBeDefined();
|
||||||
|
@ -274,6 +277,18 @@ describe('LocalStorage', () => {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should not update if the metadata match', done => {
|
||||||
|
const metadataPath = path.join(configExample.storage, pkgName, 'package.json')
|
||||||
|
const prevStat = fs.statSync(metadataPath)
|
||||||
|
storage.updateVersions(pkgName, metadata, (err, data) => {
|
||||||
|
expect(err).toBeNull()
|
||||||
|
const nextStat = fs.statSync(metadataPath)
|
||||||
|
expect(nextStat).toHaveProperty('ctime', prevStat.ctime)
|
||||||
|
expect(nextStat).toHaveProperty('mtime', prevStat.mtime)
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('LocalStorage::changePackage', () => {
|
describe('LocalStorage::changePackage', () => {
|
||||||
|
|
|
@ -82,7 +82,13 @@
|
||||||
"beta": "1.0.2",
|
"beta": "1.0.2",
|
||||||
"next": "1.0.4"
|
"next": "1.0.4"
|
||||||
},
|
},
|
||||||
"time": {},
|
"time": {
|
||||||
|
"modified": "2019-01-29T03:20:04.000Z",
|
||||||
|
"created": "2019-01-29T03:20:00.000Z",
|
||||||
|
"1.0.1": "2019-01-29T03:20:01.000Z",
|
||||||
|
"1.0.2": "2019-01-29T03:20:02.000Z",
|
||||||
|
"1.0.4": "2019-01-29T03:20:04.000Z"
|
||||||
|
},
|
||||||
"_distfiles": {},
|
"_distfiles": {},
|
||||||
"_attachments": {},
|
"_attachments": {},
|
||||||
"_uplinks": {},
|
"_uplinks": {},
|
||||||
|
|
Loading…
Add table
Reference in a new issue