本文整理汇总了TypeScript中electron-builder-util.debug函数的典型用法代码示例。如果您正苦于以下问题:TypeScript debug函数的具体用法?TypeScript debug怎么用?TypeScript debug使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了debug函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: computeFileSets
export async function computeFileSets(matchers: Array<FileMatcher>, transformer: FileTransformer, packager: Packager, isElectronCompile: boolean): Promise<Array<FileSet>> {
const fileSets: Array<FileSet> = []
for (const matcher of matchers) {
const fileWalker = new AppFileWalker(matcher, packager)
const fromStat = await statOrNull(fileWalker.matcher.from)
if (fromStat == null) {
debug(`Directory ${fileWalker.matcher.from} doesn't exists, skip file copying`)
continue
}
const files = await walk(fileWalker.matcher.from, fileWalker.filter, fileWalker)
const metadata = fileWalker.metadata
const transformedFiles = await BluebirdPromise.map(files, it => {
const fileStat = metadata.get(it)
return fileStat != null && fileStat.isFile() ? transformer(it) : null
}, CONCURRENCY)
fileSets.push({src: fileWalker.matcher.from, files, metadata: fileWalker.metadata, transformedFiles, destination: fileWalker.matcher.to})
}
const mainFileSet = fileSets[0]
if (isElectronCompile) {
// cache should be first in the asar
fileSets.unshift(await compileUsingElectronCompile(mainFileSet, packager))
}
return fileSets
}
示例2: readChildPackage
async function readChildPackage(name: string, parentDir: string, parent: any, parentDepth: number, pathToMetadata: Map<string, Dependency>): Promise<Dependency | null> {
const rawDir = path.join(parentDir, "node_modules", name)
let dir: string | null = rawDir
const stat = await lstat(dir)
const isSymbolicLink = stat.isSymbolicLink()
if (isSymbolicLink) {
dir = await orNullIfFileNotExist(realpath(dir))
if (dir == null) {
debug(`Broken symlink ${rawDir}`)
return null
}
}
const processed = pathToMetadata.get(dir)
if (processed != null) {
return processed
}
const metadata: Dependency = await orNullIfFileNotExist(readJson(path.join(dir, "package.json")))
if (metadata == null) {
return null
}
if (isSymbolicLink) {
metadata.link = dir
metadata.stat = stat
}
metadata.path = rawDir
await _readInstalled(dir, metadata, parent, name, parentDepth + 1, pathToMetadata)
return metadata
}
示例3: validateConfig
export async function validateConfig(config: Config) {
const extraMetadata = config.extraMetadata
if (extraMetadata != null) {
if (extraMetadata.build != null) {
throw new Error(`--em.build is deprecated, please specify as -c"`)
}
if (extraMetadata.directories != null) {
throw new Error(`--em.directories is deprecated, please specify as -c.directories"`)
}
}
// noinspection JSDeprecatedSymbols
if (config.npmSkipBuildFromSource === false) {
config.buildDependenciesFromSource = false
}
if (validatorPromise == null) {
validatorPromise = createConfigValidator()
}
const validator = await validatorPromise
if (!validator(config)) {
debug(JSON.stringify(validator.errors, null, 2))
throw new Error(`Config is invalid:
${JSON.stringify(normaliseErrorMessages(validator.errors!), null, 2)}
How to fix:
1. Open https://github.com/electron-userland/electron-builder/wiki/Options
2. Search the option name on the page.
* Not found? The option was deprecated or not exists (check spelling).
* Found? Check that the option in the appropriate place. e.g. "title" only in the "dmg", not in the root.
`)
}
}
示例4: readFile
const macOsVersion = new Lazy<string>(async () => {
const file = await readFile("/System/Library/CoreServices/SystemVersion.plist", "utf8")
const matches = /<key>ProductVersion<\/key>[\s\S]*<string>([\d.]+)<\/string>/.exec(file)
if (!matches) {
throw new Error("Couldn't find the macOS version")
}
debug(`macOS version: ${matches[1]}`)
return clean(matches[1])
})
示例5: debug
const wineExecutable = new Lazy<ToolInfo>(async () => {
debug(`USE_SYSTEM_WINE: ${process.env.USE_SYSTEM_WINE}`)
if (!isUseSystemWine() && await isMacOsSierra()) {
// noinspection SpellCheckingInspection
const wineDir = await getBinFromGithub("wine", "2.0.1-mac-10.12", "IvKwDml/Ob0vKfYVxcu92wxUzHu8lTQSjjb8OlCTQ6bdNpVkqw17OM14TPpzGMIgSxfVIrQZhZdCwpkxLyG3mg==")
return {
path: path.join(wineDir, "bin/wine"),
env: {
WINEDEBUG: "-all,err+all",
WINEDLLOVERRIDES: "winemenubuilder.exe=d",
WINEPREFIX: path.join(wineDir, "wine-home"),
DYLD_FALLBACK_LIBRARY_PATH: computeEnv(process.env.DYLD_FALLBACK_LIBRARY_PATH, [path.join(wineDir, "lib")])
}
}
}
await checkWineVersion(exec("wine", ["--version"]))
return {path: "wine"}
})
示例6: cleanupPackageJson
function cleanupPackageJson(data: any, isMain: boolean): any {
try {
let changed = false
for (const prop of Object.getOwnPropertyNames(data)) {
if (prop[0] === "_" || prop === "dist" || prop === "gitHead" || prop === "keywords" || prop === "build" || (isMain && prop === "devDependencies") || prop === "scripts") {
delete data[prop]
changed = true
}
}
if (changed) {
return JSON.stringify(data, null, 2)
}
}
catch (e) {
debug(e)
}
return null
}
示例7: addLicenseToDmg
export async function addLicenseToDmg(packager: PlatformPackager<any>, dmgPath: string) {
// http://www.owsiak.org/?p=700
const licenseFiles = await getLicenseFiles(packager)
if (licenseFiles.length === 0) {
return
}
if (debug.enabled) {
debug(`License files: ${licenseFiles.join(" ")}`)
}
const tempFile = await packager.getTempFile(".r")
let data = await readFile(path.join(__dirname, "..", "..", "templates", "dmg", "license.txt"), "utf8")
let counter = 5000
for (const item of licenseFiles) {
const kind = item.file.toLowerCase().endsWith(".rtf") ? "RTF" : "TEXT"
data += `data '${kind}' (${counter}, "${item.langName} SLA") {\n`
const hex = (await readFile(item.file)).toString("hex").toUpperCase()
for (let i = 0; i < hex.length; i += 32) {
data += '$"' + hex.substring(i, Math.min(i + 32, hex.length)) + '"\n'
}
data += "};\n\n"
// noinspection SpellCheckingInspection
data += `data 'styl' (${counter}, "${item.langName} SLA") {
$"0003 0000 0000 000C 0009 0014 0000 0000"
$"0000 0000 0000 0000 0027 000C 0009 0014"
$"0100 0000 0000 0000 0000 0000 002A 000C"
$"0009 0014 0000 0000 0000 0000 0000"
};`
counter++
}
await writeFile(tempFile, data)
await exec("hdiutil", ["unflatten", dmgPath])
await exec("Rez", ["-a", tempFile, "-o", dmgPath])
await exec("hdiutil", ["flatten", dmgPath])
}
示例8: releasify
async function releasify(options: SquirrelOptions, nupkgPath: string, outputDirectory: string, packageName: string) {
const args = [
"--releasify", nupkgPath,
"--releaseDir", outputDirectory
]
const out = (await exec(process.platform === "win32" ? path.join(options.vendorPath, "Update.com") : "mono", prepareArgs(args, path.join(options.vendorPath, "Update-Mono.exe")), {
maxBuffer: 4 * 1024000,
})).trim()
if (debug.enabled) {
debug(`Squirrel output: ${out}`)
}
const lines = out.split("\n")
for (let i = lines.length - 1; i > -1; i--) {
const line = lines[i]
if (line.includes(packageName)) {
return line.trim()
}
}
throw new Error(`Invalid output, cannot find last release entry, output: ${out}`)
}
示例9: cleanupPackageJson
function cleanupPackageJson(data: any, isMain: boolean): any {
const deps = data.dependencies
// https://github.com/electron-userland/electron-builder/issues/507#issuecomment-312772099
const isRemoveBabel = deps != null && typeof deps === "object" && !Object.getOwnPropertyNames(deps).some(it => it.startsWith("babel"))
try {
let changed = false
for (const prop of Object.getOwnPropertyNames(data)) {
// removing devDependencies from package.json breaks levelup in electron, so, remove it only from main package.json
if (prop[0] === "_" || ignoredPackageMetadataProperties.has(prop) || (isMain && prop === "devDependencies") || (isRemoveBabel && prop === "babel")) {
delete data[prop]
changed = true
}
}
if (changed) {
return JSON.stringify(data, null, 2)
}
}
catch (e) {
debug(e)
}
return null
}
示例10: unlink
unlink(path.join(outputDirectory, outFile.replace(".msi", ".wixpdb"))).catch(e => debug(e.toString())),