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

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

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

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



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

示例1: downloadAllGoldsAndCompare

/** Download golds screenshots. */
function downloadAllGoldsAndCompare(
  files: any[], database: admin.database.Database,
  prNumber: string) {

  mkdirp(path.join(SCREENSHOT_DIR, `golds`));
  mkdirp(path.join(SCREENSHOT_DIR, `diff`));

  return Promise.all(files.map((file: any) => {
    return downloadGold(file).then(() => diffScreenshot(file.name, database, prNumber));
  })).then((results: boolean[]) => results.every((value: boolean) => value == true));
}
开发者ID:dharmeshpipariya,项目名称:material2,代码行数:12,代码来源:screenshots.ts


示例2: syncDatasetToGitRepo

export async function syncDatasetToGitRepo(datasetId: number, options: { transaction?: db.TransactionContext, oldDatasetName?: string, commitName?: string, commitEmail?: string, commitOnly?: boolean } = {}) {
    const { oldDatasetName, commitName, commitEmail, commitOnly } = options

    const oldDatasetFilename = oldDatasetName ? filenamify(oldDatasetName) : undefined

    const datasetRepo = options.transaction ? options.transaction.manager.getRepository(Dataset) : Dataset.getRepository()

    const dataset = await datasetRepo.findOne({ id: datasetId })
    if (!dataset) {
        throw new JsonError(`No such dataset ${datasetId}`, 404)
    }

    if (dataset.isPrivate) {
        // Private dataset doesn't go in git repo
        return removeDatasetFromGitRepo(oldDatasetName||dataset.name, dataset.namespace, options)
    }

    // Not doing bulk imports for now
    if (dataset.namespace !== 'owid')
        return

    // Base repository directory for this dataspace
    const repoDir = path.join(GIT_DATASETS_DIR, dataset.namespace)

    if (!fs.existsSync(path.join(repoDir, '.git'))) {
        await fs.mkdirp(repoDir)
        await execFormatted(`cd %s && git init && git config user.name %s && git config user.email %s`, [repoDir, GIT_DEFAULT_USERNAME, GIT_DEFAULT_EMAIL])
    }

    // Output dataset to temporary directory
    const tmpDatasetDir = path.join(TMP_DIR, dataset.filename)
    await fs.mkdirp(tmpDatasetDir)

    await Promise.all([
        fs.writeFile(path.join(tmpDatasetDir, `${dataset.filename}.csv`), await dataset.toCSV()),
        fs.writeFile(path.join(tmpDatasetDir, `datapackage.json`), JSON.stringify(await dataset.toDatapackage(), null, 2)),
        fs.writeFile(path.join(tmpDatasetDir, `README.md`), await datasetToReadme(dataset))
    ])

    const datasetsDir = path.join(repoDir, "datasets")
    await fs.mkdirp(datasetsDir)

    const finalDatasetDir = path.join(datasetsDir, dataset.filename)
    const isNew = !fs.existsSync(finalDatasetDir)
    await execFormatted(`cd %s && rm -rf %s && mv %s %s && git add -A %s`, [repoDir, finalDatasetDir, tmpDatasetDir, finalDatasetDir, finalDatasetDir])

    if (oldDatasetFilename && oldDatasetFilename !== dataset.filename) {
        const oldDatasetDir = path.join(datasetsDir, oldDatasetFilename)
        await execFormatted(`cd %s && rm -rf %s && git add -A %s`, [repoDir, oldDatasetDir, oldDatasetDir])
    }

    const commitMsg = isNew ? `Adding ${dataset.filename}` : `Updating ${dataset.filename}`
    await execFormatted(`cd %s && (git diff-index --quiet HEAD || (git commit -m %s --quiet --author="${commitName||GIT_DEFAULT_USERNAME} <${commitEmail||GIT_DEFAULT_EMAIL}>"${commitOnly ? "" : " && git push))"}`, [repoDir, commitMsg])
}
开发者ID:OurWorldInData,项目名称:owid-grapher,代码行数:54,代码来源:gitDataExport.ts


示例3: async

const writeSnapshot = async (diff: Snapshot, dir: string) => {
  for (const key in diff) {
    if (diff[key] instanceof Snap) {
      await fs.mkdirp(path.dirname(path.resolve(dir, key)));
      await fs.writeFile(path.resolve(dir, key), (diff[key] as Snap).data);
    } else {
      await fs.mkdirp(path.resolve(dir, key));
      await writeSnapshot(diff[key] as Snapshot, dir);
    }
  }
};
开发者ID:electron,项目名称:electron-rebuild,代码行数:11,代码来源:cache.ts


示例4: 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


示例5: async

 const copyApp = async (newDir: string, fixture = 'initial') => {
   const appBundlePath = path.resolve(process.execPath, '../../..')
   const newPath = path.resolve(newDir, 'Electron.app')
   cp.spawnSync('cp', ['-R', appBundlePath, path.dirname(newPath)])
   const appDir = path.resolve(newPath, 'Contents/Resources/app')
   await fs.mkdirp(appDir)
   await fs.copy(path.resolve(fixturesPath, 'auto-update', fixture), appDir)
   const plistPath = path.resolve(newPath, 'Contents', 'Info.plist')
   await fs.writeFile(
     plistPath,
     (await fs.readFile(plistPath, 'utf8')).replace('<key>BuildMachineOSBuild</key>', `<key>NSAppTransportSecurity</key>
     <dict>
         <key>NSAllowsArbitraryLoads</key>
         <true/>
         <key>NSExceptionDomains</key>
         <dict>
             <key>localhost</key>
             <dict>
                 <key>NSExceptionAllowsInsecureHTTPLoads</key>
                 <true/>
                 <key>NSIncludesSubdomains</key>
                 <true/>
             </dict>
         </dict>
     </dict><key>BuildMachineOSBuild</key>`)
   )
   return newPath
 }
开发者ID:doridoridoriand,项目名称:electron,代码行数:28,代码来源:api-autoupdater-darwin-spec.ts


示例6: getScreenshotFiles

/** Get a list of filenames from firebase database. */
function getScreenshotFiles(database: firebase.database.Database) {
  mkdirp(LOCAL_GOLDENS);
  mkdirp(LOCAL_DIFFS);

  return database.ref(FIREBASE_DATA_GOLDENS).once('value')
      .then((snapshot: firebase.database.DataSnapshot) => {
    let counter = 0;
    snapshot.forEach((childSnapshot: firebase.database.DataSnapshot) => {
      let key = childSnapshot.key;
      let binaryData = new Buffer(childSnapshot.val(), 'base64').toString('binary');
      writeFileSync(`${LOCAL_GOLDENS}/${key}.screenshot.png`, binaryData, 'binary');
      counter++;
      if (counter == snapshot.numChildren()) {
        return true;
      }
    });
  }).catch((error: any) => console.log(error));
}
开发者ID:attilacsanyi,项目名称:material2,代码行数:19,代码来源:screenshots.ts


示例7: run

async function run() {
  await fs.mkdirp(cacheDir)

  const { lat, lon } = await getLatLon()
  debug('lat %o, lon: %o', lat, lon)
  const weather = await getWeather({ lat, lon })
  debug('got weather: %s', weather.daily.summary)
  console.log(`${getIcon(weather.currently)} ${temp(weather.currently)}`)
}
开发者ID:dickeyxxx,项目名称:tmux-weather,代码行数:9,代码来源:tmux-weather.ts


示例8: Promise

 return new Promise((resolve, reject) => {
   fse.mkdirp(path.dirname(destination), error => {
     if (error) {
       reject(error);
     } else {
       fse.writeFileSync(destination, license + content);
       resolve(destination);
     }
   });
 });
开发者ID:angular,项目名称:material-tools,代码行数:10,代码来源:MaterialTools.ts


示例9: initCache

  protected async initCache(
    token  : string,
    userId : string,
  ): Promise<void> {
    log.verbose('PuppetPadchatManager', 'initCache(%s, %s)', token, userId)

    if (   this.cacheContactRawPayload
        || this.cacheRoomMemberRawPayload
        || this.cacheRoomRawPayload
    ) {
      throw new Error('cache exists')
    }

    const baseDir = path.join(
      os.homedir(),
      path.sep,
      '.wechaty',
      'puppet-padchat-cache',
      path.sep,
      token,
      path.sep,
      userId,
    )

    const baseDirExist = await fs.pathExists(baseDir)

    if (!baseDirExist) {
      await fs.mkdirp(baseDir)
    }

    this.cacheContactRawPayload    = new FlashStoreSync(path.join(baseDir, 'contact-raw-payload'))
    this.cacheRoomMemberRawPayload = new FlashStoreSync(path.join(baseDir, 'room-member-raw-payload'))
    this.cacheRoomRawPayload       = new FlashStoreSync(path.join(baseDir, 'room-raw-payload'))

    await Promise.all([
      this.cacheContactRawPayload.ready(),
      this.cacheRoomMemberRawPayload.ready(),
      this.cacheRoomRawPayload.ready(),
    ])

    const roomMemberTotalNum = [...this.cacheRoomMemberRawPayload.values()].reduce(
      (accuVal, currVal) => {
        return accuVal + Object.keys(currVal).length
      },
      0,
    )

    log.verbose('PuppetPadchatManager', 'initCache() inited %d Contacts, %d RoomMembers, %d Rooms, cachedir="%s"',
                                      this.cacheContactRawPayload.size,
                                      roomMemberTotalNum,
                                      this.cacheRoomRawPayload.size,
                                      baseDir,
              )
  }
开发者ID:miggame,项目名称:wechaty,代码行数:54,代码来源:padchat-manager.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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