当前位置: 首页>>代码示例>>TypeScript>>正文


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

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


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

示例1: it

    it('can commit when staged new file is then deleted', async () => {
      let status,
        files = null

      const repo = await setupEmptyRepository()

      const firstPath = path.join(repo.path, 'first')
      const secondPath = path.join(repo.path, 'second')

      await FSE.writeFile(firstPath, 'line1\n')
      await FSE.writeFile(secondPath, 'line2\n')

      await GitProcess.exec(['add', '.'], repo.path)

      await FSE.unlink(firstPath)

      status = await getStatusOrThrow(repo)
      files = status.workingDirectory.files

      expect(files.length).to.equal(1)
      expect(files[0].path).to.contain('second')
      expect(files[0].status).to.equal(AppFileStatus.New)

      const toCommit = status.workingDirectory.withIncludeAllFiles(true)

      await createCommit(repo, 'commit everything', toCommit.files)

      status = await getStatusOrThrow(repo)
      files = status.workingDirectory.files
      expect(files).to.be.empty

      const commit = await getCommit(repo, 'HEAD')
      expect(commit).to.not.be.null
      expect(commit!.summary).to.equal('commit everything')
    })
开发者ID:soslanashkhotov,项目名称:desktop,代码行数:35,代码来源:commit-test.ts

示例2: Promise

 return new Promise((resolve, reject) => {
   unlink(filePath, (err: Error) => {
     if (err) {
       return reject(err);
     }
     return resolve();
   });
 });
开发者ID:Kode-Kitchen,项目名称:ionic-app-scripts,代码行数:8,代码来源:helpers.ts

示例3: it

    it('returns empty when path is missing', async () => {
      const repo = await setupEmptyRepository()
      const path = Path.join(repo.path, '.git', 'description')
      await FSE.unlink(path)

      const actual = await getGitDescription(repo.path)
      expect(actual).equals('')
    })
开发者ID:ghmoore,项目名称:desktop,代码行数:8,代码来源:description-test.ts

示例4: reject

 return new Promise<void>((resolve, reject) => {
   fs.unlink(p, err => {
     if (err) {
       reject(err);
     } else {
       resolve();
     }
   });
 });
开发者ID:headinclouds,项目名称:angular-cli,代码行数:9,代码来源:build.ts

示例5: mkdirp

 return Promise.all(IterableX.from(files).map(async ([newPath, newSource]) => {
   const filePath = path.join(outDir, newPath);
   await mkdirp(path.dirname(filePath));
   if (newSource !== undefined) {
     await fse.writeFile(filePath, newSource);
   } else if (await fse.pathExists(filePath)) {
     await fse.unlink(filePath);
   }
 }));
开发者ID:,项目名称:,代码行数:9,代码来源:

示例6: reject

        fs.exists(path, exists => {
            if (exists) {
                // TODO: Should we check after unlinking to see if the file still exists?
                fs.unlink(path, err => {
                    if (err) {
                        return reject(err);
                    }

                    resolve();
                });
            }
        });
开发者ID:rlugojr,项目名称:omnisharp-vscode,代码行数:12,代码来源:assets.ts

示例7: archiveAsync

 await mio.usingAsync(seriesChapter.iteratorAsync(), async iterator => {
   try {
     await archiveAsync(chapter, iterator);
     chapter.finalize();
     await fs.rename(chapterPath + shared.extension.tmp, chapterPath);
     console.log(`Finished ${seriesChapter.name} (${timer})`);
   } catch (error) {
     await fs.unlink(chapterPath + shared.extension.tmp);
     throw error;
   } finally {
     chapter.abort();
   }
 });
开发者ID:Deathspike,项目名称:mangarack,代码行数:13,代码来源:download.ts

示例8: clearVisitedPage

function clearVisitedPage(id) {
    if (!visitedPages[id].pinned) {
        io.emit("deleteKey", {
            name: 'visitedPages',
            key: id
        });
        if (visitedPages[id].progress == 100) {
            //  download completed but user requested to clear
            // delete downloaded file
            FILE.unlink(path.join(FILES_PATH, '../', visitedPages[id].path));
            delete visitedPages[id];
        } else {
            // download is in progress
            // partial file will be deleted by middleware function
            visitedPages[id].cleared = true;
        }
    }
}
开发者ID:jazz19972,项目名称:n00b,代码行数:18,代码来源:server.ts

示例9: percentage

 data.stream.on('data', (chunk) => {
     downloadedLength += chunk.length;
     var progress = percentage((downloadedLength / totalLength));
     if (visitedPages[uniqid]) {
         if (visitedPages[uniqid].cleared) { //download cancelled
             stream.close();
             FILE.unlink(completeFilePath);  //delete incomplete file
             delete visitedPages[uniqid];
             io.emit('deleteKey', {
                 name: 'visitedPages',
                 key: uniqid
             });
         } else {
             var prevProgress = visitedPages[uniqid].progress;
             if ((progress - prevProgress) > 0.1 || progress == 100) {  //don't clog the socket
                 visitedPages[uniqid].progress = progress;
                 visitedPages[uniqid].downloaded = prettyBytes(downloadedLength);
                 sendVisitedPagesUpdate(io, uniqid);
             }
         }
     }
 });
开发者ID:jazz19972,项目名称:n00b,代码行数:22,代码来源:server.ts

示例10: async

    it.skip('resets discarded staged file', async () => {
      const repoPath = repository!.path
      const fileName = 'README.md'
      const filePath = path.join(repoPath, fileName)

      // modify the file
      await FSE.writeFile(filePath, 'Hi world\n')

      // stage the file, then delete it to mimic discarding
      GitProcess.exec(['add', fileName], repoPath)
      await FSE.unlink(filePath)

      await resetPaths(repository!, GitResetMode.Mixed, 'HEAD', [filePath])

      // then checkout the version from the index to restore it
      await GitProcess.exec(
        ['checkout-index', '-f', '-u', '-q', '--', fileName],
        repoPath
      )

      const status = await getStatusOrThrow(repository!)
      expect(status.workingDirectory.files.length).to.equal(0)
    })
开发者ID:ghmoore,项目名称:desktop,代码行数:23,代码来源:reset-test.ts


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