Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function commonArch(currentIfNotSpecified: boolean): Array {
if (platform === Platform.MAC) {
return args.x64 || currentIfNotSpecified ? [Arch.x64] : []
}
const result = Array()
if (args.x64) {
result.push(Arch.x64)
}
if (args.armv7l) {
result.push(Arch.armv7l)
}
if (args.arm64) {
result.push(Arch.arm64)
}
if (args.ia32) {
result.push(Arch.ia32)
}
for (const type of types) {
const suffixPos = type.lastIndexOf(":")
if (suffixPos > 0) {
addValue(archToType, archFromString(type.substring(suffixPos + 1)), type.substring(0, suffixPos))
}
else {
for (const arch of commonArch(true)) {
addValue(archToType, arch, type)
}
}
}
}
if (args.mac != null) {
processTargets(Platform.MAC, args.mac)
}
if (args.linux != null) {
processTargets(Platform.LINUX, args.linux)
}
if (args.win != null) {
processTargets(Platform.WINDOWS, args.win)
}
if (targets.size === 0) {
processTargets(Platform.current(), [])
}
const result: any = {...args}
result.targets = targets
export function createTargets(platforms: Array, type?: string | null, arch?: string | null): Map>> {
const targets = new Map>>()
for (const platform of platforms) {
const archs = platform === Platform.MAC ? [Arch.x64] : (arch === "all" ? [Arch.x64, Arch.ia32] : [archFromString(arch == null ? process.arch : arch)])
const archToType = new Map>()
targets.set(platform, archToType)
for (const arch of archs) {
archToType.set(arch, type == null ? [] : [type])
}
}
return targets
}