本文整理汇总了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 })
}
})
示例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());
}
示例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);
}
示例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);
}
}
示例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) {
}
}
}
示例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));
}
};
示例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);
}
};
示例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;
}
示例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}已经存在`);
}
}
});
示例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;
}