Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Ignore sub-vendor package #1253

Merged
merged 1 commit into from
Oct 1, 2017
Merged
Changes from all commits
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
5 changes: 3 additions & 2 deletions src/goPackages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,15 @@ function getRelativePackagePath(currentFileDirPath: string, currentWorkspace: st
vendorIndex = 0;
}
}
// Check if current file and the vendor pkg belong to the same root project
// Check if current file and the vendor pkg belong to the same root project and not sub vendor
// If yes, then vendor pkg can be replaced with its relative path to the "vendor" folder
// If not, then the vendor pkg should not be allowed to be imported.
if (vendorIndex > -1) {
let rootProjectForVendorPkg = path.join(currentWorkspace, pkgPath.substr(0, vendorIndex));
let relativePathForVendorPkg = pkgPath.substring(vendorIndex + magicVendorString.length);
let subVendor = relativePathForVendorPkg.indexOf('/vendor/') !== -1;

if (relativePathForVendorPkg && currentFileDirPath.startsWith(rootProjectForVendorPkg)) {
if (relativePathForVendorPkg && currentFileDirPath.startsWith(rootProjectForVendorPkg) && !subVendor) {
return relativePathForVendorPkg;
}
return '';
Expand Down