Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
beyondkmp committed Oct 31, 2024
1 parent b9fcfed commit 71fd764
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/app-builder-lib/src/asar/unpackDetector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export function detectUnpackedDirs(fileSet: ResolvedFileSet, autoUnpackDirs: Set
for (let i = 0, n = fileSet.files.length; i < n; i++) {
const file = fileSet.files[i]
const stat: FilterStats = metadata.get(file)!
if (!stat.destNodeModulesDirPath || autoUnpackDirs.has(stat.destNodeModulesDirPath.replace(/\\/g, "/"))) {
if (!stat.destNodeModulesDirPath || autoUnpackDirs.has(stat.destNodeModulesDirPath)) {
continue
}

Expand All @@ -42,6 +42,6 @@ export function detectUnpackedDirs(fileSet: ResolvedFileSet, autoUnpackDirs: Set
if (log.isDebugEnabled) {
log.debug({ file: stat.destNodeModulesFilePath, reason: "contains executable code" }, "not packed into asar archive")
}
autoUnpackDirs.add(stat.destNodeModulesDirPath.replace(/\\/g, "/"))
autoUnpackDirs.add(stat.destNodeModulesDirPath)
}
}
9 changes: 4 additions & 5 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,18 +283,17 @@ test.ifLinuxOrDevMac("beforeBuild", () => {
)
})

test("win smart unpack", () => {
test.ifDevOrWinCi("win smart unpack", () => {
// test onNodeModuleFile hook
const nodeModuleFiles: Array<string> = []
let p = ""
return app(
{
targets: Platform.WINDOWS.createTarget(DIR_TARGET),
config: {
npmRebuild: true,
onNodeModuleFile: file => {
const name = toSystemIndependentPath(path.relative(p, file))
console.log("test is her,", p, file, nodeModuleFiles, name)
const index = file.indexOf(path.sep + "node_modules"+ path.sep)
const name = toSystemIndependentPath(file.slice(index + 1))
if (!name.startsWith(".") && !name.endsWith(".dll") && name.includes(".")) {
nodeModuleFiles.push(name)
}
Expand All @@ -305,8 +304,8 @@ test("win smart unpack", () => {
},
},
{
isInstallDepsBefore:true,
projectDirCreated: projectDir => {
p = projectDir
return packageJson(it => {
it.dependencies = {
debug: "3.1.0",
Expand Down

0 comments on commit 71fd764

Please sign in to comment.