本文整理汇总了TypeScript中builder-util/out/promise.orNullIfFileNotExist函数的典型用法代码示例。如果您正苦于以下问题:TypeScript orNullIfFileNotExist函数的具体用法?TypeScript orNullIfFileNotExist怎么用?TypeScript orNullIfFileNotExist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了orNullIfFileNotExist函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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
}
示例2: getGitUrlFromGitConfig
async function getGitUrlFromGitConfig(projectDir: string): Promise<string | null> {
const data = await orNullIfFileNotExist(readFile(path.join(projectDir, ".git", "config"), "utf8"))
if (data == null) {
return null
}
const conf = data.split(/\r?\n/)
const i = conf.indexOf('[remote "origin"]')
if (i !== -1) {
let u = conf[i + 1]
if (!u.match(/^\s*url =/)) {
u = conf[i + 2]
}
if (u.match(/^\s*url =/)) {
return u.replace(/^\s*url = /, "")
}
}
return null
}