Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
for (const arch of archs == null ? defaultArchs : asArray(archs)) {
addValue(result, archFromString(arch), name)
}
}
if (result.size === 0) {
const defaultTarget = platformPackager.defaultTarget
if (raw.size === 0 && platform === Platform.LINUX && (process.platform === "darwin" || process.platform === "win32")) {
result.set(Arch.x64, defaultTarget)
// cannot enable arm because of native dependencies - e.g. keytar doesn't provide pre-builds for arm
// result.set(Arch.armv7l, ["snap"])
}
else {
for (const arch of defaultArchs) {
result.set(archFromString(arch), defaultTarget)
}
}
}
return result
}
const defaultArchs: Array = raw.size === 0 ? [platform === Platform.MAC ? "x64" : process.arch as ArchType] : Array.from(raw.keys()).map(it => Arch[it] as ArchType)
const result = new Map(raw)
for (const target of asArray(platformPackager.platformSpecificBuildOptions.target).map(it => typeof it === "string" ? {target: it} : it)) {
let name = target.target
let archs = target.arch
const suffixPos = name.lastIndexOf(":")
if (suffixPos > 0) {
name = target.target.substring(0, suffixPos)
if (archs == null) {
archs = target.target.substring(suffixPos + 1) as ArchType
}
}
for (const arch of archs == null ? defaultArchs : asArray(archs)) {
addValue(result, archFromString(arch), name)
}
}
if (result.size === 0) {
const defaultTarget = platformPackager.defaultTarget
if (raw.size === 0 && platform === Platform.LINUX && (process.platform === "darwin" || process.platform === "win32")) {
result.set(Arch.x64, defaultTarget)
// cannot enable arm because of native dependencies - e.g. keytar doesn't provide pre-builds for arm
// result.set(Arch.armv7l, ["snap"])
}
else {
for (const arch of defaultArchs) {
result.set(archFromString(arch), defaultTarget)
}
}
}
archToType = new Map>()
targets.set(platform, archToType)
}
if (types.length === 0) {
const defaultTargetValue = args.dir ? [DIR_TARGET] : []
for (const arch of commonArch(args.dir === true)) {
archToType.set(arch, defaultTargetValue)
}
return
}
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)
}
}
}
}
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)
}
return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result
}
if (archToType == null) {
archToType = new Map>()
targets.set(platform, archToType)
}
if (types.length === 0) {
for (const arch of commonArch(false)) {
archToType.set(arch, [])
}
return
}
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)
}
}
}
}
function commonArch(currentIfNotSpecified: boolean): Array {
if (platform === Platform.MAC) {
return currentIfNotSpecified ? [Arch.x64] : []
}
const result = Array()
return result.length === 0 && currentIfNotSpecified ? [archFromString(process.arch)] : result
}
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
}