本文整理匯總了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;
}