• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript fs-extra.readdirSync函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中fs-extra.readdirSync函数的典型用法代码示例。如果您正苦于以下问题:TypeScript readdirSync函数的具体用法?TypeScript readdirSync怎么用?TypeScript readdirSync使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了readdirSync函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: searchFiles

	searchFiles(current: any) {
		if (current === undefined) {
			for (let sub of this.subProjects) sub.searchFiles(undefined);
			this.searchFiles(this.basedir);
			// std::set<std::string> starts;
			// for (std::string include : includes) {
			//     if (!isAbsolute(include)) continue;
			//     std::string start = include.substr(0, firstIndexOf(include, '*'));
			//     if (starts.count(start) > 0) continue;
			//     starts.insert(start);
			//     searchFiles(Paths::get(start));
			// }
			return;
		}

		let files = fs.readdirSync(current);
		nextfile: for (let f in files) {
			let file = path.join(current, files[f]);
			if (fs.statSync(file).isDirectory()) continue;
			// if (!current.isAbsolute())
			file = path.relative(this.basedir, file);
			for (let exclude of this.excludes) {
				if (this.matches(this.stringify(file), exclude)) continue nextfile;
			}
			for (let includeobject of this.includes) {
				let include = includeobject.file;
				if (isAbsolute(include)) {
					let inc = include;
					inc = path.relative(this.basedir, inc);
					include = inc;
				}
				if (this.matches(this.stringify(file), include)) {
					this.addFileForReal(this.stringify(file), includeobject.options);
				}
			}
		}

		let dirs = fs.readdirSync(current);
		nextdir: for (let d of dirs) {
			let dir = path.join(current, d);
			if (d.startsWith('.')) continue;
			if (!fs.statSync(dir).isDirectory()) continue;
			for (let exclude of this.excludes) {
				if (this.matchesAllSubdirs(path.relative(this.basedir, dir), exclude)) {
					continue nextdir;
				}
			}
			this.searchFiles(dir);
		}
	}
开发者ID:hammeron-art,项目名称:koremake,代码行数:50,代码来源:Project.ts


示例2: Promise

 return new Promise((resolve, reject) => {
   const [fileName] = fs.readdirSync(dir).filter(name => name.match(regex));
   if (!fileName) {
     reject(new Error(`File ${regex} was expected to exist but not found...`));
   }
   resolve(fileName);
 });
开发者ID:3L4CKD4RK,项目名称:angular-cli,代码行数:7,代码来源:fs.ts


示例3: getFoldersInFolder

export function getFoldersInFolder(
  folder: string,
  filter: ((folder: string) => boolean) | null,
  recursive: boolean,
  subFolder: string,
) {
  const fullFolder =
    typeof subFolder === 'undefined' ? folder : path.join(folder, subFolder);
  const folderFiles = fs.readdirSync(fullFolder);

  let folders: string[] = [];
  folderFiles.forEach(function(file: string) {
    if (filter && filter(file)) {
      console.log(path.join(fullFolder, file) + ' removed by filter');
      return;
    }

    const stat = fs.statSync(path.join(fullFolder, file));
    const subFolderFileName =
      typeof subFolder === 'undefined' ? file : path.join(subFolder, file);

    if (stat.isDirectory()) {
      folders.push(subFolderFileName);
      if (recursive) {
        folders = folders.concat(
          getFilesInFolder(folder, filter, recursive, subFolderFileName),
        );
      }
    }
  });

  return folders.map(function(folder) {
    return folder.replace(/\\/g, '/');
  });
}
开发者ID:igor-bezkrovny,项目名称:texturer,代码行数:35,代码来源:utils.ts


示例4: compileShader

function compileShader(projectDir, type, from, to, temp, platform, nokrafix) {
	let compiler = '';
	
	if (Project.koreDir !== '') {
		if (nokrafix) {
			compiler = path.resolve(Project.koreDir, 'Tools', 'kfx', 'kfx' + exec.sys());
		}
		else {
			compiler = path.resolve(Project.koreDir, 'Tools', 'krafix', 'krafix' + exec.sys());
		}
	}

	if (fs.existsSync(path.join(projectDir.toString(), 'Backends'))) {
		let libdirs = fs.readdirSync(path.join(projectDir.toString(), 'Backends'));
		for (let ld in libdirs) {
			let libdir = path.join(projectDir.toString(), 'Backends', libdirs[ld]);
			if (fs.statSync(libdir).isDirectory()) {
				let exe = path.join(libdir, 'krafix', 'krafix-' + platform + '.exe');
				if (fs.existsSync(exe)) {
					compiler = exe;
				}
			}
		}
	}

	if (compiler !== '') {
		child_process.spawnSync(compiler, [type, from, to, temp, platform]);
	}
}
开发者ID:romamik,项目名称:koremake,代码行数:29,代码来源:main.ts


示例5: emptyDirectory

export function emptyDirectory (dirPath: string, opts: { excludes: string[] } = { excludes: [] }) {
  if (fs.existsSync(dirPath)) {
    fs.readdirSync(dirPath).forEach(file => {
      const curPath = path.join(dirPath, file)
      if (fs.lstatSync(curPath).isDirectory()) {
        let removed = false
        let i = 0 // retry counter
        do {
          try {
            if (!opts.excludes.length || !opts.excludes.some(item => curPath.indexOf(item) >= 0)) {
              emptyDirectory(curPath)
              fs.rmdirSync(curPath)
            }
            removed = true
          } catch (e) {
          } finally {
            if (++i < retries) {
              continue
            }
          }
        } while (!removed)
      } else {
        fs.unlinkSync(curPath)
      }
    })
  }
}
开发者ID:YangShaoQun,项目名称:taro,代码行数:27,代码来源:index.ts


示例6: init

function init() {
    if (!fs.existsSync(rootPath)) {
        return;
    }
    console.log('init------start ');
    let fileList: string[] = fs.readdirSync(rootPath);
    docsLoadingState = false;
    asyncjs.eachSeries(fileList, (file, callback) => {
        if (!fs.statSync(rootPath + file).isDirectory()) {
            return callback(null);
        }
        fs.readFile(rootPath + file + '/db.json', { encoding: 'utf-8' }, (err, data) => {
            if (err) {
                console.log('load file ' + file + 'error:' + err);
            } else {
                docsDB[file] = JSON.parse(data);
            }
            callback(null);
        });
    }, err => {
        if (!err) {
            docsLoadingState = true;
        }
        console.log('init------end ');
    });
}
开发者ID:snippetmodule,项目名称:docs-search-client,代码行数:26,代码来源:docs.ts


示例7: copyFilesFromSrcToOutput

 taroSelfComponents.forEach(c => {
   const cPath = path.join(taroJsQuickAppComponentsPath, c)
   const cMainPath = path.join(cPath, 'index')
   const cFiles = fs.readdirSync(cPath).map(item => path.join(cPath, item))
   copyFilesFromSrcToOutput(cFiles, (sourceFilePath, outputFilePath) => {
     if (fs.existsSync(sourceFilePath)) {
       const fileContent = fs.readFileSync(sourceFilePath).toString()
       const match = SCRIPT_CONTENT_REG.exec(fileContent)
       if (match) {
         const scriptContent = match[1]
         const transformResult: IWxTransformResult = wxTransformer({
           code: scriptContent,
           sourcePath: sourceFilePath,
           sourceDir: getBuildData().sourceDir,
           outputPath: outputFilePath,
           isNormal: true,
           isTyped: false,
           adapter: BUILD_TYPES.QUICKAPP
         })
         const res = parseAst(PARSE_AST_TYPE.NORMAL, transformResult.ast, [], sourceFilePath, outputFilePath)
         const newFileContent = fileContent.replace(SCRIPT_CONTENT_REG, `<script>${res.code}</script>`)
         fs.ensureDirSync(path.dirname(outputFilePath))
         fs.writeFileSync(outputFilePath, newFileContent)
       }
     }
   })
   const cRelativePath = promoteRelativePath(path.relative(filePath, cMainPath.replace(BuildData.nodeModulesPath, BuildData.npmOutputDir)))
   importTaroSelfComponents.add({
     path: cRelativePath,
     name: c
   })
 })
开发者ID:YangShaoQun,项目名称:taro,代码行数:32,代码来源:helper.ts


示例8: getSiblingSassFiles

function getSiblingSassFiles(componentPath: string, sassConfig: SassConfig) {
  return readdirSync(componentPath).filter(f => {
    return isValidSassFile(f, sassConfig);
  }).map(f => {
    return join(componentPath, f);
  });
}
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:7,代码来源:sass.ts


示例9: walkFolder

function walkFolder(targetFolder: string, cb: (fileName: string) => void) {
	let items = fse.readdirSync(targetFolder)

	let files: string[] = []
	let folders: string[] = []

	items.forEach(item => {
		let itemPath = path.join(targetFolder, item)
		let stat = fse.statSync(itemPath)

		if (stat.isDirectory()) {
			folders.push(itemPath)
		} else {
			files.push(itemPath)
		}
	})

	for (const item of files) {
		if (path.extname(item) === '.json') {
			cb(item)
		}
	}

	for (const item of folders) {
		walkFolder(item, cb)
	}
}
开发者ID:docscript,项目名称:docscript,代码行数:27,代码来源:walker.ts


示例10: eachFile

/**
 * Invoke the supplied callback for each file (not directories) in the supplied directory.
 *
 * @package util
 */
export default function eachFile(dirpath: string, fn: (childpath: string) => void): void {
  fs.readdirSync(dirpath).forEach((childpath) => {
    let absolutepath = path.join(dirpath, childpath);
    if (fs.statSync(absolutepath).isFile()) {
      fn(childpath);
    }
  });
}
开发者ID:acburdine,项目名称:denali,代码行数:13,代码来源:each-file.ts



注:本文中的fs-extra.readdirSync函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.remove函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.readdir函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap