當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs.lstatSync函數代碼示例

本文整理匯總了TypeScript中fs.lstatSync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript lstatSync函數的具體用法?TypeScript lstatSync怎麽用?TypeScript lstatSync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了lstatSync函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: return

 return (globs || []).some(glob => {
   try {
     const globStat = lstatSync(join(configDir, glob))
     const newGlob = glob.length === 0 ? '.' : glob
     const globToMatch = globStat.isDirectory() ? `${glob}/**` : glob
     return minimatch(filePath, globToMatch, { matchBase: true })
   } catch (error) {
     // Out of errors that lstat provides, EACCES and ENOENT are the
     // most likely. For both cases, run the match with the raw glob
     // and return the result.
     return minimatch(filePath, glob, { matchBase: true })
   }
 })
開發者ID:graphcool,項目名稱:graphql-config,代碼行數:13,代碼來源:utils.ts

示例2: checkDictonariesInstalled

function checkDictonariesInstalled(): Promise<any> {
    let dictionariesRootPath = readDictionaryConfig();
    try {
        let isDirectory = fs.lstatSync(dictionariesRootPath);
        if (isDirectory) {
            return Promise.resolve(true);
        }
    }
    catch (err) {
       // Directory does not exist 
    }
    return downloadManager.downloadAndInstallServer(path.resolve(dictionariesRootPath, ".."), readUrlConfig());
}
開發者ID:silverbulleters,項目名稱:vsc-spellchecker,代碼行數:13,代碼來源:requirements.ts

示例3: add

 private add(changes: IPendingChange[], newChange: IPendingChange, ignoreFolders: boolean) {
     // Deleted files won't exist, but we still include them in the results
     if (ignoreFolders && fs.existsSync(newChange.localItem)) {
         // check to see if the local item is a file or folder
         const f: string = newChange.localItem;
         const stats: any = fs.lstatSync(f);
         if (stats.isDirectory()) {
             // It's a directory/folder and we don't want those
             return;
         }
     }
     changes.push(newChange);
 }
開發者ID:Microsoft,項目名稱:vsts-vscode,代碼行數:13,代碼來源:status.ts

示例4: copyTree

function copyTree(sourcePath: string, destPath: string): void {
    if (!fs.existsSync(sourcePath))
        throw "Copy tree source doesn't exist: " + sourcePath;
    if (!fs.lstatSync(sourcePath).isDirectory()) // File
        return copyFile(sourcePath, destPath);

    // Directory
    if (!fs.existsSync(destPath))
        mkdirParentsSync(destPath);
    else if (!fs.lstatSync(destPath).isDirectory())
        throw "Can't copy a directory onto a file: " + sourcePath + " " + destPath;

    var filesInDir = fs.readdirSync(sourcePath);
    for (var i = 0; i < filesInDir.length; i++) {
        var filename = filesInDir[i];
        var file = sourcePath + "/" + filename;
        if (fs.lstatSync(file).isDirectory())
            copyTree(file, destPath + "/" + filename);
        else
            copyFile(file, destPath);
    }
}
開發者ID:PlayFab,項目名稱:SDKGenerator,代碼行數:22,代碼來源:generate.ts

示例5: tryCreateProgram

    static tryCreateProgram(project?: string): Program {
        if (typeof project === 'string') {
            try {
                if (lstatSync(project).isDirectory()) {
                    project = join(project, 'tsconfig.json');
                }

                return TslintPreprocessor.createProgram(project);
            } catch (e) {

            }
        }
    }
開發者ID:yisraelx,項目名稱:karma-tslint,代碼行數:13,代碼來源:tslint.preprocessor.ts

示例6: copyDir

export const copyDir = (src: string, dest: string) => {
  const srcStat = fs.lstatSync(src);
  if (srcStat.isDirectory()) {
    if (!fs.existsSync(dest)) {
      fs.mkdirSync(dest);
    }
    fs.readdirSync(src).map(filePath =>
      copyDir(path.join(src, filePath), path.join(dest, filePath)),
    );
  } else {
    fs.writeFileSync(dest, fs.readFileSync(src));
  }
};
開發者ID:Volune,項目名稱:jest,代碼行數:13,代碼來源:Utils.ts

示例7: async

 const deleteFolderRecursive = async (path: string) => {
   if (await exists(path)) {
     for (const file of await readdir(path)) {
       var curPath = path + "/" + file;
       if (lstatSync(curPath).isDirectory()) {
         await deleteFolderRecursive(curPath);
       } else {
         unlinkSync(curPath);
       }
     }
     rmdirSync(path);
   }
 };
開發者ID:lmazuel,項目名稱:autorest,代碼行數:13,代碼來源:uri.ts

示例8: getFilesInDirectory

	public getFilesInDirectory(directoryPath, ignoreList?: string[]) : any {
		var dirContents = fs.readdirSync(directoryPath);
		var files = []; 

		for (var index in dirContents) {
			var fullPath = path.join(directoryPath, dirContents[index]);
			if (fs.lstatSync(fullPath).isFile()) {
				files.push(fullPath);
			}
		}

		return files;
	}
開發者ID:duffman,項目名稱:packman,代碼行數:13,代碼來源:filesystem.helper.ts

示例9: parseFileToRoute

    dirs.forEach(dir => {
        let state = fs.lstatSync(root + '/' + dir);

        if (state.isFile()) {
            var route: Route = parseFileToRoute(dir);
            if (!allRoutes[route.routePath]) {
                console.log(`添加${route.routePath}到路由組合,已經可以接收${route.routePath}的請求`);
                allRoutes[route.routePath] = route;
            } else {
                console.error(`出現掃描錯誤,${route.routePath}已經存在`);
            }
        }
    });
開發者ID:gujiajia,項目名稱:node.js,代碼行數:13,代碼來源:scanner.ts

示例10: fileOrDirectoryExists

	public fileOrDirectoryExists(source: string, isFile?: boolean): boolean {
		var sourceExists = false;
		
		if (fs.existsSync(source)) {
			var stat = fs.lstatSync(source);

			if (stat.isFile() || stat.isDirectory()) {
				sourceExists = true;
			}
		}
		
		return sourceExists;
	}
開發者ID:duffman,項目名稱:packman,代碼行數:13,代碼來源:filesystem.helper.ts


注:本文中的fs.lstatSync函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。