Skip to content
Open
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
34 changes: 30 additions & 4 deletions __test__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,21 @@ describe('main', () => {
expect(fs.existsSync(binDir)).toBeTruthy()

const executablePath = path.join(binDir, 'mytool-with-resource')
const bundlePath = path.join(
const resourceBundlePath = path.join(
binDir,
'mytool-with-resource_mytool-with-resource.bundle'
)
expect(fs.existsSync(executablePath)).toBeTruthy()
expect(fs.existsSync(bundlePath)).toBeTruthy()
expect(fs.existsSync(resourceBundlePath)).toBeTruthy()

// Verify resource bundle contents are copied correctly
expect(fs.statSync(resourceBundlePath).isDirectory()).toBeTruthy()
const resourceBundleContents = fs.readdirSync(resourceBundlePath)
expect(resourceBundleContents).toContain('note.txt')

// Verify the file content is preserved
const noteFilePath = path.join(resourceBundlePath, 'note.txt')
expect(fs.existsSync(noteFilePath)).toBeTruthy()
}
}
})
Expand Down Expand Up @@ -298,18 +307,35 @@ describe('main', () => {
const macosPlatformDir = platformDirs.find((dir) =>
path.basename(dir).endsWith('macos')
)
expect(macosPlatformDir).toBeDefined()
if (!macosPlatformDir) {
throw new Error('macos platform directory not found')
}

// Verify universal triple directory exists
const universalTripleDir = path.join(
macosPlatformDir!,
macosPlatformDir,
'universal-apple-macosx'
)
expect(fs.existsSync(universalTripleDir)).toBeTruthy()

// Verify executable exists in the universal triple directory
const executablePath = path.join(universalTripleDir, 'bin', 'myexecutable')
expect(fs.existsSync(executablePath)).toBeTruthy()

// Verify only universal variant exists (no single-arch variants)
const tripleDirs = fs
.readdirSync(macosPlatformDir)
.filter((f) => fs.statSync(path.join(macosPlatformDir, f)).isDirectory())
expect(tripleDirs).toEqual(['universal-apple-macosx'])

// Verify resource bundle is included in universal variant
const resourceBundlePath = path.join(
universalTripleDir,
'bin',
'myexecutable_myexecutable.bundle'
)
expect(fs.existsSync(resourceBundlePath)).toBeTruthy()
expect(fs.statSync(resourceBundlePath).isDirectory()).toBeTruthy()
})

it('should fail when configuration is not provided', async () => {
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 15 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 15 additions & 1 deletion src/collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,21 @@ class ExecutableCollector {
}
}

return executables
// Filter out single-arch variants that are already covered by Universal binaries
const universalTriples = new Set<string>()
for (const exe of executables) {
if (exe.getTriples().length > 1) {
for (const triple of exe.getTriples()) {
universalTriples.add(triple)
}
}
}

return executables.filter((exe) => {
const triples = exe.getTriples()
if (triples.length > 1) return true
return !universalTriples.has(triples[0])
})
}
}

Expand Down
Loading