當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。