當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript fs-extra.mkdtemp函數代碼示例

本文整理匯總了TypeScript中fs-extra.mkdtemp函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript mkdtemp函數的具體用法?TypeScript mkdtemp怎麽用?TypeScript mkdtemp使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了mkdtemp函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: async

 const withTempDirectory = async (fn: (dir: string) => Promise<void>) => {
   const dir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-update-spec-'))
   try {
     await fn(dir)
   } finally {
     cp.spawnSync('rm', ['-r' , dir])
   }
 }
開發者ID:doridoridoriand,項目名稱:electron,代碼行數:8,代碼來源:api-autoupdater-darwin-spec.ts

示例2: reject

 return new Promise<string>((resolve, reject) => {
   const tempDir = Path.join(Os.tmpdir(), `${name}-`)
   Fs.mkdtemp(tempDir, (err, directory) => {
     if (err) {
       reject(err)
     } else {
       const fullPath = Path.join(directory, name)
       resolve(fullPath)
     }
   })
 })
開發者ID:Ahskys,項目名稱:desktop,代碼行數:11,代碼來源:file-system.ts

示例3: it

      it('should copy the electron dir to the build dir if everything is ok and enabled', async () => {
        const electronDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-tmp-'));
        await fs.writeFile(path.resolve(electronDir, 'electron'), 'hi i am electron I swear');
        p.config.electronPath = electronDir;
        const fn = p.getHook('packageAfterExtract')!;

        await fn(null, tmpDir, null, process.platform, process.arch);

        expect(await fs.pathExists(path.resolve(tmpDir, 'touch'))).to.equal(false);
        expect(await fs.pathExists(path.resolve(tmpDir, 'electron'))).to.equal(true);
        expect(await fs.readFile(path.resolve(tmpDir, 'electron'), 'utf8')).to.equal('hi i am electron I swear');
      });
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:12,代碼來源:LocalElectronPlugin_spec.ts

示例4: fn

export async function withTempDirectory<T>(fn: (directory: string) => Promise<T>): Promise<T> {
  const directory = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-download-'));

  let result: T;
  try {
    result = await fn(directory);
  } catch (err) {
    await fs.remove(directory);
    throw err;
  }

  try {
    await fs.remove(directory);
  } catch {
    // Ignore error, it's just a temp dir
  }
  return result;
}
開發者ID:electron-userland,項目名稱:electron-download,代碼行數:18,代碼來源:utils.ts

示例5: Buffer

fs.fchmod(fd, modeNum, errorCallback);
fs.fchmod(fd, modeStr, errorCallback);
fs.fchmodSync(fd, modeNum);
fs.fchmodSync(fd, modeStr);
fs.lchmod(path, modeStr, errorCallback);
fs.lchmod(path, modeNum, errorCallback);
fs.lchmodSync(path, modeNum);
fs.lchmodSync(path, modeStr);
fs.statSync(path);
fs.lstatSync(path);

fs.read(0, new Buffer(""), 0, 0, null).then(x => {
	const a = x.buffer;
	const b = x.bytesRead;
});

fs.write(0, new Buffer(""), 0, 0, null).then(x => {
	const a = x.buffer;
	const b = x.bytesWritten;
});

// $ExpectType Promise<void>
fs.writeFile("foo.txt", "i am foo", { encoding: "utf-8" });

// $ExpectType Promise<string>
fs.mkdtemp("foo");

fs.copyFile("src", "dest").then();
fs.copyFile("src", "dest", fs.constants.COPYFILE_EXCL).then();
fs.copyFile("src", "dest", errorCallback);
開發者ID:csrakowski,項目名稱:DefinitelyTyped,代碼行數:30,代碼來源:fs-extra-tests.ts

示例6: before

 before(async () => {
   dir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-forge-test-'));
 });
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:3,代碼來源:publish_spec.ts

示例7: getTempFilePath

export async function getTempFilePath(name: string): Promise<string> {
  const tempDir = Path.join(Os.tmpdir(), `${name}-`)
  const directory = await FSE.mkdtemp(tempDir)
  return Path.join(directory, name)
}
開發者ID:ghmoore,項目名稱:desktop,代碼行數:5,代碼來源:file-system.ts

示例8: beforeEach

 beforeEach(async () => {
   tmpDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'forge-test-'));
   await fs.writeFile(path.resolve(tmpDir, 'touch'), 'hey');
 });
開發者ID:balloonzzq,項目名稱:electron-forge,代碼行數:4,代碼來源:LocalElectronPlugin_spec.ts

示例9: it

			it('All Files with `--dest`', async () => {
				const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'eclint-'));
				expect(tmpDir).to.be.ok.and.be.a('string');
				const files = await eclint(['fix', '--dest', tmpDir]);
				expect(files).to.have.length.above(10);
			});
開發者ID:jedmao,項目名稱:eclint,代碼行數:6,代碼來源:cli.spec.ts

示例10: beforeEach

 beforeEach(async () => {
   cacheDir = await fs.mkdtemp(path.resolve(os.tmpdir(), 'electron-download-spec-'));
   cache = new Cache(cacheDir);
 });
開發者ID:electron-userland,項目名稱:electron-download,代碼行數:4,代碼來源:Cache.spec.ts


注:本文中的fs-extra.mkdtemp函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。