Skip to content

Commit

Permalink
Optimizes a bit the lockfile parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanis committed May 19, 2019
1 parent 173f180 commit 5c6c036
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/berry-core/sources/Project.ts
Expand Up @@ -34,6 +34,8 @@ import {LinkType}
// the Package type; no more no less.
const LOCKFILE_VERSION = 3;

const MULTIPLE_KEYS_REGEXP = / *, */g;

export type InstallOptions = {
cache: Cache,
fetcher?: Fetcher,
Expand Down Expand Up @@ -117,6 +119,7 @@ export class Project {
this.storedPackages = new Map();

const lockfilePath = ppath.join(this.cwd, this.configuration.get(`lockfileFilename`));
const defaultLanguageName = this.configuration.get(`defaultLanguageName`);

if (xfs.existsSync(lockfilePath)) {
const content = await xfs.readFilePromise(lockfilePath, `utf8`);
Expand All @@ -138,7 +141,7 @@ export class Project {

const version = manifest.version;

const languageName = manifest.languageName || this.configuration.get(`defaultLanguageName`);
const languageName = manifest.languageName || defaultLanguageName;
const linkType = data.linkType as LinkType;

const dependencies = manifest.dependencies;
Expand All @@ -157,7 +160,7 @@ export class Project {
this.storedPackages.set(pkg.locatorHash, pkg);
}

for (const entry of key.split(/ *, */g)) {
for (const entry of key.split(MULTIPLE_KEYS_REGEXP)) {
const descriptor = structUtils.parseDescriptor(entry);

this.storedDescriptors.set(descriptor.descriptorHash, descriptor);
Expand Down

0 comments on commit 5c6c036

Please sign in to comment.