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