当前位置: 首页>>代码示例>>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;未经允许,请勿转载。