当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript fs-extra-p.lstat函数代码示例

本文整理汇总了TypeScript中fs-extra-p.lstat函数的典型用法代码示例。如果您正苦于以下问题:TypeScript lstat函数的具体用法?TypeScript lstat怎么用?TypeScript lstat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了lstat函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
开发者ID:yuya-oc,项目名称:electron-builder,代码行数:31,代码来源:packageDependencies.ts

示例2: _readInstalled

async function _readInstalled(folder: string, parent: any | null, name: string | null, depth: number, opts: any, realpathSeen: Map<string, Dependency>, findUnmetSeen: Set<any>): Promise<any> {
  const realDir = await realpath(folder)

  const processed = realpathSeen.get(realDir)
  if (processed != null) {
    return processed
  }

  const obj = await readJson(path.resolve(folder, "package.json"))
  obj.realPath = realDir
  obj.path = obj.path || folder
  //noinspection ES6MissingAwait
  if ((await lstat(folder)).isSymbolicLink()) {
    obj.link = realDir
  }

  obj.realName = name || obj.name
  obj.dependencyNames = obj.dependencies == null ? null : new Set(Object.keys(obj.dependencies))

  // Mark as extraneous at this point.
  // This will be un-marked in unmarkExtraneous, where we mark as not-extraneous everything that is required in some way from the root object.
  obj.extraneous = true
  obj.optional = true

  if (parent != null && obj.link == null) {
    obj.parent = parent
  }

  realpathSeen.set(realDir, obj)

  if (depth > opts.depth) {
    return obj
  }

  const deps = await BluebirdPromise.map(await readScopedDir(path.join(folder, "node_modules")), pkg => _readInstalled(path.join(folder, "node_modules", pkg), obj, pkg, depth + 1, opts, realpathSeen, findUnmetSeen), {concurrency: 8})
  if (obj.dependencies != null) {
    for (const dep of deps) {
      obj.dependencies[dep.realName] = dep
    }

    // any strings in the obj.dependencies are unmet deps. However, if it's optional, then that's fine, so just delete it.
    if (obj.optionalDependencies != null) {
      for (const dep of Object.keys(obj.optionalDependencies)) {
        if (typeof obj.dependencies[dep] === "string") {
          delete obj.dependencies[dep]
        }
      }
    }
  }

  return obj
}
开发者ID:mbrainiac,项目名称:electron-builder,代码行数:52,代码来源:readInstalled.ts

示例3: lstat

    const sortedFilePaths = await BluebirdPromise.map(childNames, name => {
      if (name === ".DS_Store" || name === ".gitkeep") {
        return null
      }

      const filePath = dirPath + path.sep + name
      return lstat(filePath)
        .then(stat => {
          if (filter != null && !filter(filePath, stat)) {
            return null
          }

          const consumerResult = consumer == null ? null : consumer.consume(filePath, stat, dirPath, childNames)
          if (consumerResult === false) {
            return null
          }
          else if (consumerResult == null || !("then" in consumerResult)) {
            if (stat.isDirectory()) {
              dirs.push(name)
              return null
            }
            else {
              return filePath
            }
          }
          else {
            return (consumerResult as Promise<any>)
              .then((it): any => {
                if (it != null && Array.isArray(it)) {
                  nodeModuleContent = it
                  return null
                }

                // asarUtil can return modified stat (symlink handling)
                if ((it != null && "isDirectory" in it ? (it as Stats) : stat).isDirectory()) {
                  dirs.push(name)
                  return null
                }
                else {
                  return filePath
                }
              })
          }
        })
    }, CONCURRENCY)
开发者ID:electron-userland,项目名称:electron-builder,代码行数:45,代码来源:fs.ts

示例4: isSymbolicLink

 async isSymbolicLink() {
   const info = await lstat(this.actual)
   if (!info.isSymbolicLink()) {
     throw new Error(`Path ${this.actual} is not a symlink`)
   }
 }
开发者ID:ledinhphuong,项目名称:electron-builder,代码行数:6,代码来源:fileAssert.ts

示例5: onNodeModuleFile

        const sortedFilePaths = await BluebirdPromise.map(childNames, name => {
          if (onNodeModuleFile != null) {
            onNodeModuleFile(dirPath + path.sep + name)
          }

          if (excludedFiles.has(name) || name.startsWith("._")) {
            return null
          }

          for (const ext of nodeModuleExcludedExts) {
            if (name.endsWith(ext)) {
              return null
            }
          }

          // noinspection SpellCheckingInspection
          if (isTopLevel && (topLevelExcludedFiles.has(name) || (moduleName === "libui-node" && (name === "build" || name === "docs" || name === "src")))) {
            return null
          }

          if (dirPath.endsWith("build")) {
            if (name === "gyp-mac-tool" || name === "Makefile" || name.endsWith(".mk") || name.endsWith(".gypi") || name.endsWith(".Makefile")) {
              return null
            }
          }
          else if (dirPath.endsWith("Release") && (name === ".deps" || name === "obj.target")) {
            return null
          }
          else if (name === "src" && (dirPath.endsWith("keytar") || dirPath.endsWith("keytar-prebuild"))) {
            return null
          }
          else if (dirPath.endsWith("lzma-native") && (name === "build" || name === "deps")) {
            return null
          }

          const filePath = dirPath + path.sep + name
          return lstat(filePath)
            .then(stat => {
              if (filter != null && !filter(filePath, stat)) {
                return null
              }

              if (!stat.isDirectory()) {
                metadata.set(filePath, stat)
              }
              const consumerResult = this.handleFile(filePath, dirPath, stat)
              if (consumerResult == null) {
                if (stat.isDirectory()) {
                  dirs.push(name)
                  return null
                }
                else {
                  return filePath
                }
              }
              else {
                return consumerResult
                  .then(it => {
                    // asarUtil can return modified stat (symlink handling)
                    if ((it == null ? stat : it).isDirectory()) {
                      dirs.push(name)
                      return null
                    }
                    else {
                      return filePath
                    }
                  })
              }
            })
        }, CONCURRENCY)
开发者ID:electron-userland,项目名称:electron-builder,代码行数:70,代码来源:NodeModuleCopyHelper.ts


注:本文中的fs-extra-p.lstat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。