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


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

本文整理汇总了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;未经允许,请勿转载。