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

fix: Path does not end with the package name #8560

Merged
merged 6 commits into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
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: 5 additions & 0 deletions .changeset/swift-apricots-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"app-builder-lib": patch
---

fix: Path does not end with the package name
10 changes: 5 additions & 5 deletions packages/app-builder-lib/src/util/appFileCopier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,13 @@ export async function computeNodeModuleFileSets(platformPackager: PlatformPackag
let index = 0
const NODE_MODULES = "node_modules"
const getRealSource = (name: string, source: string) => {
const normalizedName = name.split("/").join(path.sep)
if (!source.endsWith(normalizedName)) {
throw new Error("Path does not end with the package name")
}
let parentDir = path.dirname(source)

const scopeDepth = name.split("/").length
// get the parent dir of the package, input: /root/path/node_modules/@electron/remote, output: /root/path/node_modules
const parentDir = source.slice(0, -normalizedName.length - 1)
for (let i = 0; i < scopeDepth - 1; i++) {
parentDir = path.dirname(parentDir)
}

// for the local node modules which is not in node modules
if (!parentDir.endsWith(path.sep + NODE_MODULES)) {
Expand Down
4 changes: 3 additions & 1 deletion test/src/globTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ test.ifAll.ifDevOrLinuxCi("ignore node_modules", () => {
//noinspection SpellCheckingInspection
data.dependencies = {
"ci-info": "2.0.0",
"@electron/remote": "2.1.2",
"@types/node": "14.17.0",
// this contains string-width-cjs 4.2.3
"@isaacs/cliui":"8.0.2"
}
}),
packed: context => {
Expand Down
Loading