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

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

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

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



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

示例1: found

(async () => {
  const dirsToCheck = [];

  for (const subDir of await fs.readdir(PACKAGES_DIR)) {
    for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
      dirsToCheck.push(path.resolve(PACKAGES_DIR, subDir, packageDir));
    }
  }

  let bad = false;
  for (const dir of dirsToCheck) {
    const pj = await fs.readJson(path.resolve(dir, 'package.json'));
    if (pj.name === '@electron-forge/cli') continue;
    if (!await fs.pathExists(path.resolve(dir, pj.main))) {
      console.error(`${`[${pj.name}]`.cyan}:`,  `Main entry not found (${pj.main})`.red);
      bad = true;
    }
    if (!pj.typings || !await fs.pathExists(path.resolve(dir, pj.typings))) {
      console.error(`${`[${pj.name}]`.cyan}:`, `Typings entry not found (${pj.typings})`.red);
      bad = true;
    }
  }

  if (bad) {
    process.exit(1);
  }
})().catch(console.error);
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:27,代码来源:test-dist.ts


示例2: it

      it('should create dry run hash JSON files', async () => {
        expect(makeStub.callCount).to.equal(2);
        const dryRunFolder = path.resolve(dir, 'out', 'publish-dry-run');
        expect(await fs.pathExists(dryRunFolder)).to.equal(true);

        const hashFolders = await fs.readdir(dryRunFolder);
        expect(hashFolders).to.have.length(2, 'Should contain two hashes (two publishes)');
        for (const hashFolderName of hashFolders) {
          const hashFolder = path.resolve(dryRunFolder, hashFolderName);
          const makes = await fs.readdir(hashFolder);
          expect(makes).to.have.length(3, 'Should contain the results of three makes');
          for (const makeJson of makes) {
            const jsonPath = path.resolve(hashFolder, makeJson);
            const contents = await fs.readFile(jsonPath, 'utf8');
            expect(() => JSON.parse(contents), 'Should be valid JSON').to.not.throw();
            const data = JSON.parse(contents);
            expect(data).to.have.property('artifacts');
            expect(data).to.have.property('platform');
            expect(data).to.have.property('arch');
            expect(data).to.have.property('packageJSON');

            // Make the artifacts for later
            for (const artifactPath of data.artifacts) {
              await fs.mkdirp(path.dirname(path.resolve(dir, artifactPath)));
              await fs.writeFile(path.resolve(dir, artifactPath), artifactPath);
            }
          }
        }
      });
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:29,代码来源:publish_spec.ts


示例3: function

export const refresh = async function () {
  const paths = await ConfigService.getPaths();
  const versions = [];
  for (const path of paths) {
    const versionPaths = [
      npath.join(path, 'versions'),
      npath.join(path, '.minecraft', 'versions'),
      npath.join(path, 'minecraft', 'versions'),
    ]
    let versionPath = '';
    for (versionPath of versionPaths) {
      if (await fs.pathExists(versionPath)) {
        break;
      }
    }
    if (!versionPath) {
      continue;
    }
    const dirs = await fs.readdir(versionPath);
    for (const dir of dirs) {
      const detailPath = npath.join(versionPath, dir);
      const stat = await fs.stat(detailPath);
      if (!stat.isDirectory()) continue;
      const files = await fs.readdir(detailPath);
      if (!files.some((file) => !!file.match(/.json$/))) {
        continue;
      }
      let jsonFile;
      let json;
      for (const file of files) {
        if (!file.endsWith('.json')) continue;
        const path = npath.join(detailPath, file);
        let content = await fs.readFile(path, 'utf8');
        try {
          content = JSON.parse(content);
        } catch (e) {}
        if (content && content['minecraftArguments']) {
          jsonFile = path;
          json = content;
          break;
        }
      }
      versions.push({
        name: dir,
        versionPath: detailPath,
        minecraftPath: npath.join(versionPath, '..'),
        jsonFile,
        json,
      });
    }
  }
  return versions;
}
开发者ID:bangbang93,项目名称:BMCLJS,代码行数:53,代码来源:game.ts


示例4:

(async () => {
  const dirsToLink = [];

  for (const subDir of await fs.readdir(PACKAGES_DIR)) {
    for (const packageDir of await fs.readdir(path.resolve(PACKAGES_DIR, subDir))) {
      dirsToLink.push(path.resolve(PACKAGES_DIR, subDir, packageDir));
    }
  }

  for (const dir of dirsToLink) {
    await fs.copy(path.resolve(BASE_DIR, 'tsconfig.json'), path.resolve(dir, 'tsconfig.json'));
    await fs.copy(path.resolve(BASE_DIR, 'tslint.json'), path.resolve(dir, 'tslint.json'));
  }
})();
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:14,代码来源:link-ts.ts


示例5:

    return Promise.resolve().then(() => {
        let data = _.cloneDeep(tree);

        if (data.numberOfUsers === 0)
            return data;
        else {
            let promises: Promise<void>[] = [];
            for (let steamDirectory in data.tree) {
                for (let userId in data.tree[steamDirectory]) {
                    promises.push(
                        fs.readdir(path.join(steamDirectory, 'userdata', userId, 'config', 'grid')).then((files) => {
                            let extRegex = /png|tga|jpg|jpeg/i;
                            for (let i = 0; i < files.length; i++) {
                                let ext = path.extname(files[i]);
                                let appId = path.basename(files[i], ext);
                                if (data.tree[steamDirectory][userId][appId] === undefined) {
                                    if (extRegex.test(ext))
                                        data.tree[steamDirectory][userId][appId] = path.join(steamDirectory, 'userdata', userId, 'config', 'grid', files[i]);
                                }
                            }
                        }).catch((error) => {
                            if (error.code !== 'ENOENT')
                                throw error;
                        })
                    );
                }
            }
            return Promise.all(promises).then(() => data);
        }
    });
开发者ID:kencinder,项目名称:steam-rom-manager,代码行数:30,代码来源:get-grid-image-for-tree.ts


示例6: resolve

    readDirectory: (dir, callback) => {

        fs.readdir(dir, (err, listing) => {
            if (err) return callback(err);

            const statPromises = listing

            // Take away dot-files and directories, we won't list those
                .filter(name => name.charAt(0) !== ".")

                // Map them onto promises that will return the output info for each entry
                .map(name => new Promise((resolve, reject) => {

                    getFileOutputInfo(dir + path.sep + name, (err, info) => {
                        if (err) return reject(err);

                        return resolve(info)
                    });

                }));

            Promise.all(statPromises).then(
                resolution => callback(null, resolution),
                rejection => callback(rejection)
            );
        });
    },
开发者ID:hmenager,项目名称:composer,代码行数:27,代码来源:fs.controller.ts


示例7: downloadSeriesAsync

 await mio.usingAsync(mio.Browser.createAsync(), async browser => {
   let fileNames = await fs.readdir(shared.path.normal());
   for (let fileName of fileNames) {
     let fileExtension = path.extname(fileName);
     if (fileExtension === shared.extension.json) {
       let metaProviderPath = shared.path.normal(fileName);
       let metaProvider = await fs.readJson(metaProviderPath) as shared.IMetaProvider;
       for (let url in metaProvider) {
         let timer = new mio.Timer();
         let awaiter = mio.scrapeAsync(browser, url);
         if (awaiter) {
           console.log(`Awaiting ${url}`);
           await mio.usingAsync(awaiter, async series => {
             if (series.title !== metaProvider[url]) throw new Error(`Series at ${url} property changed: title`)
             if (series.url !== url) throw new Error(`Series at ${url} property changed: url`);
             console.log(`Fetching ${series.title}`);
             await mio.commands.updateSeriesAsync(series);
             await downloadSeriesAsync(series);
             console.log(`Finished ${series.title} (${timer})`);
           });
         } else {
           console.log(`Rejected ${url}`);
         }
       }
     }
   }
 });
开发者ID:Deathspike,项目名称:mangarack,代码行数:27,代码来源:download.ts


示例8: function

router.get("/listsearch", function (req: any, res: any) {
    //var glob = require("glob")

    fs.readdir(appRoot + "\\nodulus_modules\\", function (err: any, files: Array<string>) {
        var arrRes: Array<any> = [];
        for (var i = 0; i < files.length; i++) {
            if (files[i].indexOf(".zip") > -1 && files[i].indexOf(req.query.name) > -1)
                arrRes.push(files[i].replace(".zip", ""))
        }
        res.json(arrRes);
    });
    
    
    //     // options is optional
    //     glob(appRoot + "\\nodulus_modules\\*" + req.query.name + "*/*.zip",  function (er, files) {
    //         res.json(files);
    //   // files is an array of filenames.
    //   // If the `nonull` option is set, and nothing
    //   // was found, then files is ["**/*.js"]
    //   // er is an error object or null.
    //     })
    

     
});
开发者ID:gitter-badger,项目名称:nodulus,代码行数:25,代码来源:modules.ts


示例9: readdir

export async function readdir(dir: string): Promise<string[]> {
  try {
    return await fs.readdir(dir);
  } catch (e) {
    return [];
  }
}
开发者ID:driftyco,项目名称:ionic-cli,代码行数:7,代码来源:safe.ts


示例10: read

 public async read(): Promise<ObjectMap> {
   let result: ObjectMap = {};
   for (let file of await fs.readdir(this.path)) {
     result[this.getId(file)] = await this.loadFile(join(this.path, file));
   }
   return result;
 }
开发者ID:samizdatjs,项目名称:tashmetu-fs,代码行数:7,代码来源:directory.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript fs-extra.readdirSync函数代码示例发布时间:2022-05-25
下一篇:
TypeScript fs-extra.readJsonSync函数代码示例发布时间: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