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