當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。