Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Skip already installed modules #2176

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/package-linker.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default class PackageLinker {

//
const queue: Map<string, CopyQueueItem> = new Map();
const skipped: string[] = [];
for (const [dest, {pkg, loc: src}] of flatTree) {
const ref = pkg._reference;
invariant(ref, 'expected package reference');
Expand All @@ -137,6 +138,15 @@ export default class PackageLinker {
phantomFiles.push(path.join(dest, file));
}

try {
let obj = await fs.readJson(dest + "\\package.json");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path shouldn't contain \\ as that is only valid for Windows. This should use path.join(dest, 'package.json') instead to work for all OSes.

// If the package is installed and is the exact same version, skip
if(obj.version == ref.version) {
skipped.push(dest);
continue;
}
}catch(ex) {};

queue.set(dest, {
src,
dest,
Expand All @@ -147,6 +157,7 @@ export default class PackageLinker {
},
});
}
this.reporter.info('skipped ' + skipped.length + ' modules because they are already installed');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be a string here, it should use this.reporter.lang like everywhere else.


// keep track of all scoped paths to remove empty scopes after copy
const scopedPaths = new Set();
Expand Down Expand Up @@ -183,6 +194,11 @@ export default class PackageLinker {
}
}

// skipped modules
for(const loc of skipped){
possibleExtraneous.delete(loc);
}

//
let tick;
await fs.copyBulk(Array.from(queue.values()), this.reporter, {
Expand Down
3 changes: 1 addition & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


abab@^1.0.0:
version "1.0.3"
resolved "https://registry.yarnpkg.com/abab/-/abab-1.0.3.tgz#b81de5f7274ec4e756d797cd834f303642724e5d"
Expand Down Expand Up @@ -5409,3 +5407,4 @@ yargs@~3.27.0:
os-locale "^1.4.0"
window-size "^0.1.2"
y18n "^3.2.0"