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


TypeScript kissfs.FileSystemReadSync类代码示例

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


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

示例1: createFs

export function createFs(fileSystem: FileSystemReadSync): any {
    return {
        readFileSync(path: string) {
            path = !legacyBehvior && isWindows ? `/${path.slice(path.lastIndexOf(':') + 1).replace(/\\/g, '/')}` : path;

            return fileSystem.loadTextFileSync(path).toString();
        },
        statSync(path: string) {
            path = !legacyBehvior && isWindows ? `/${path.slice(path.lastIndexOf(':') + 1).replace(/\\/g, '/')}` : path;

            const s = fileSystem.statSync(path);

            const stat = {
                type: s.type,
                isDirectory() {
                    return s.type === 'dir';
                },
                isFile() {
                    return s.type === 'file';
                },
                mtime: new Date(Date.now())
            };

            return stat;
        },
        readlinkSync(_path: string) {
            return null; // require('fs').readlinkSync(_path);
        }
    };
}
开发者ID:wix,项目名称:stylable-intelligence,代码行数:30,代码来源:provider-factory.ts

示例2: createDocFs

export function createDocFs(fileSystem: FileSystemReadSync, docs: MinimalDocs): ExtendedFSReadSync {
    return {
        __proto__: fileSystem,
        async loadTextFile(path: string) {
            return this.loadTextFileSync(path);
        },
        loadTextFileSync(path: string) {
            const vscodePath: string = toVscodePath(path);
            const fromDocs = docs.get(vscodePath);
            return fromDocs ? fromDocs.getText() : fileSystem.loadTextFileSync(fromVscodePath(path));
        },
        loadDirectoryTreeSync(path: string) {
            return fileSystem.loadDirectoryTreeSync(path);
        },
        get(path: string) {
            return (
                docs.get(path) || TextDocument.create(path, 'stylable', 0, this.loadTextFileSync(fromVscodePath(path)))
            );
        },
        getOpenedFiles() {
            return docs.keys();
        }
    } as any;
}
开发者ID:wix,项目名称:stylable-intelligence,代码行数:24,代码来源:server-utils.ts

示例3: readFile

 function readFile(filePath: string): string | undefined {
     try {
         return syncFs.loadTextFileSync(filePath);
     } catch {
         return;
     }
 }
开发者ID:wix,项目名称:stylable-intelligence,代码行数:7,代码来源:temp-language-service-host.ts

示例4: fileExists

 function fileExists(fullPath: string) {
     try {
         syncFs.loadTextFileSync(fullPath);
         return true;
     } catch (error) {
         return false;
     }
 }
开发者ID:wix,项目名称:stylable-intelligence,代码行数:8,代码来源:temp-language-service-host.ts

示例5: getFileSystemEntries

 function getFileSystemEntries(path: string): ts.FileSystemEntries {
     const files: string[] = [];
     const directories: string[] = [];
     const entries = syncFs.loadDirectoryChildrenSync(path);
     for (const entry of entries) {
         if (entry.type === 'file') {
             files.push(entry.name);
         } else {
             directories.push(entry.name);
         }
     }
     return { files, directories };
 }
开发者ID:wix,项目名称:stylable-intelligence,代码行数:13,代码来源:temp-language-service-host.ts


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