• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

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

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了lstat函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: verifyWorkspaceContainsDirectory

// Verifies that the test workspace contains the given directory
export default async function verifyWorkspaceContainsDirectory(
  args: ActionArgs
) {
  const directory = args.nodes.text()
  const fullPath = path.join(args.configuration.workspace, directory)
  args.formatter.name(
    `verifying the ${chalk.bold(
      chalk.cyan(directory)
    )} directory exists in the test workspace`
  )
  args.formatter.log(`ls ${fullPath}`)
  let stats
  try {
    stats = await fs.lstat(fullPath)
  } catch (err) {
    throw new Error(
      `directory ${chalk.cyan(
        chalk.bold(directory)
      )} does not exist in the test workspace`
    )
  }
  if (!stats.isDirectory()) {
    throw new Error(
      `${chalk.cyan(chalk.bold(directory))} exists but is not a directory`
    )
  }
}
开发者ID:Originate,项目名称:tutorial-runner,代码行数:28,代码来源:verify-workspace-contains-directory.ts


示例2: checkWorkspaceInformationMatchesWorkspaceFolder

    /**
     * TODO: Remove function when https://github.com/OmniSharp/omnisharp-roslyn/issues/909 is resolved.
     * 
     * Note: serverUtils.requestWorkspaceInformation only retrieves one folder for multi-root workspaces. Therefore, generator will be incorrect for all folders
     * except the first in a workspace. Currently, this only works if the requested folder is the same as the server's solution path or folder.
     */
    private async checkWorkspaceInformationMatchesWorkspaceFolder(folder: vscode.WorkspaceFolder | undefined): Promise<boolean> {
        const solutionPathOrFolder: string = this.server.getSolutionPathOrFolder();

        // Make sure folder, folder.uri, and solutionPathOrFolder are defined.
        if (!folder || !folder.uri || !solutionPathOrFolder)
        {
            return Promise.resolve(false);
        }

        let serverFolder = solutionPathOrFolder;
        // If its a .sln file, get the folder of the solution.
        return fs.lstat(solutionPathOrFolder).then(stat => {
            return stat.isFile();
        }).then(isFile => {
            if (isFile)
            {
                serverFolder = path.dirname(solutionPathOrFolder);
            }

            // Get absolute paths of current folder and server folder.
            const currentFolder = path.resolve(folder.uri.fsPath);
            serverFolder = path.resolve(serverFolder);

            return currentFolder && folder.uri && isSubfolderOf(serverFolder, currentFolder);
        });
    }
开发者ID:gregg-miskelly,项目名称:omnisharp-vscode,代码行数:32,代码来源:configurationProvider.ts


示例3: catch

        async.each(files, (filepath, fileRead) => {
            let strPath;
            try {
                strPath = path.join(folderPath, filepath);
            } catch (e) {
                return fileRead(null);
            }

            fs.lstat(strPath, (err, stat) => {
                if (err || !stat) {
                    return fileRead(null);
                }


                const relevance = getRelevance(strPath);
                if (relevance > threshold) {
                    results.push({
                        path: strPath,
                        relevance
                    });
                }

                if (stat.isDirectory()) {
                    recurseFolder(strPath, (err) => {
                        return fileRead(null);
                    })
                } else {
                    return fileRead(null);
                }
            });


        }, (err) => {
开发者ID:hmenager,项目名称:composer,代码行数:33,代码来源:fuzzy-search-worker.ts


示例4: readdirRecursive

export default async function* readdirRecursive(
  dir: Path
): AsyncIterableIterator<Path> {
  for (const file of await fs.readdir(dir)) {
    const fullPath = path.join(dir, file);
    const stats = await fs.lstat(fullPath);

    if (stats.isDirectory()) {
      for await (const pth of readdirRecursive(fullPath)) {
        yield pth;
      }
    } else {
      yield fullPath;
    }
  }
}
开发者ID:jlenoble,项目名称:generator-wupjs,代码行数:16,代码来源:readdir-recursive.ts


示例5: readFiles

/** 列举出文件夹内的所有文件 */
async function readFiles(input: string) {
    const ans: string[] = [];
    const dirs = await fs.readdir(input);

    for (let i = 0; i < dirs.length; i++) {
        const folder = join(input, dirs[i]);
        const stat = await fs.lstat(folder);

        if (stat.isDirectory()) {
            ans.push(...(await readFiles(folder)));
        }
        else {
            ans.push(folder);
        }
    }

    return ans;
}
开发者ID:rectification,项目名称:circuitlab,代码行数:19,代码来源:ant-icons-loader.ts


示例6: getFileOutputInfo

function getFileOutputInfo(filePath, callback) {

    fs.lstat(filePath, (err, stats) => {
        if (err) return callback(err);

        getPotentialCWLClassFromFile(filePath, (err, cwlClass) => {
            if (err) return callback(err);

            let isReadable = true;
            let isWritable = true;

            fs.access(filePath, fs.constants.R_OK, (err) => {
                if (err) isReadable = false;

                fs.access(filePath, fs.constants.W_OK, (err) => {
                    if (err) isWritable = false;

                    callback(null, {
                        type: cwlClass,
                        path: filePath,
                        name: path.basename(filePath),
                        isDir: stats.isDirectory(),
                        isFile: stats.isFile(),
                        dirname: path.dirname(filePath),
                        language: stats.isFile() ? filePath.split(".").pop() : "",
                        isWritable,
                        isReadable
                    });
                });
            });

        });


    });
}
开发者ID:hmenager,项目名称:composer,代码行数:36,代码来源:fs.controller.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.lstatSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.existsSync函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap