当前位置: 首页>>代码示例>>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;未经允许,请勿转载。