How to use the tmp-promise.dir function in tmp-promise

To help you get started, we’ve selected a few tmp-promise examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trufflesuite / ganache-core / src / ledgers / ethereum / database.ts View on Github external
private async _initialize() {
    const levelupOptions: any = { valueEncoding: "binary" };
    const store = this.options.db;
    let db;
    if (store) {
      db = await levelup(store as any, levelupOptions);
    } else {
      let directory = this.options.dbPath;
      if (!directory) {
        const dirInfo = await dir(tmpOptions);
        directory = dirInfo.path;
        this._cleanupDirectory = dirInfo.cleanup;

        // don't continue if we closed while we were waiting for the dir
        if (this.closed) return this._cleanup();
      }
      this.directory = directory;
      const store = encode(leveldown(directory), levelupOptions);
      db = await levelup(store, {});
    }

    // don't continue if we closed while we were waiting for the db
    if (this.closed) return this._cleanup();

    const open = db.open();
    this.trie = sub(db, "trie", levelupOptions);
github aragon / aragon-cli / packages / cli / src / commands / apm_cmds / publish.js View on Github external
task: async (ctx, task) => {
          // Create temporary directory
          if (!publishDir) {
            const { path: tmpDir } = await tmp.dir()
            publishDir = tmpDir
          }

          await prepareFilesForPublishing(publishDir, files, ignore)
          ctx.pathToPublish = publishDir

          return `Files copied to temporary directory: ${ctx.pathToPublish}`
        },
      },
github tommy351 / kosko / packages / cli / src / commands / __tests__ / init.ts View on Github external
beforeEach(async () => {
    tmpDir = await tmp.dir({ unsafeCleanup: true });
  });
github shoutem / cli / src / services / packer.js View on Github external
export default async function shoutemPack(dir, options) {
  const packedDirectories = ['app', 'server'].map(d => path.join(dir, d));

  if (!await hasExtensionsJson(dir)) {
    throw new Error(`${dir} cannot be packed because it has no extension.json file.`);
  }

  await await offerDevNameSync(dir);

  const tmpDir = (await tmp.dir()).path;
  const packageDir = path.join(tmpDir, 'package');

  await fs.mkdir(packageDir);

  const dirsToPack = await Promise.filter(packedDirectories, hasPackageJson);

  if (options.nobuild) {
    console.error('Skipping build step due to --nobuild flag.');
  } else {
    await spinify(buildNodeProject(path.join(dir, 'server')), 'Building the server part...', 'OK');
    await spinify(buildNodeProject(path.join(dir, 'app')), 'Building the app part...', 'OK');
  }

  return await spinify(async () => {
    for (const partDir of dirsToPack) {
      await npmPack(partDir, packageDir);
github googleapis / github-repo-automation / src / lib / update-repo.ts View on Github external
async function processRepository(
  repository: GitHubRepository,
  updateCallback: Function,
  branch: string,
  message: string,
  comment: string,
  reviewers: string[]
) {
  const tmpDir = await tmp.dir({unsafeCleanup: true});

  const cloneUrl = repository.getRepository().ssh_url;
  await exec(`git clone ${cloneUrl} ${tmpDir.path}`);

  let filesToUpdate;
  try {
    filesToUpdate = await updateCallback(tmpDir.path);
  } catch (err) {
    console.warn(
      '  callback function threw an exception, skipping this repository',
      err ? err.stack : ''
    );
    return;
  }

  if (filesToUpdate === undefined) {
github concourse / concourse / web / wats / helpers / fly.js View on Github external
async setupHome() {
    this.home = await tmp.dir({ unsafeCleanup: true });
  }
github atomist / automation-client / lib / spi / clone / tmpDirectoryManager.ts View on Github external
public async directoryFor(owner: string, repo: string, branch: string, opts: CloneOptions): Promise {
        this.initialize();
        const fromTmp = await tmp.dir({ keep: opts.keep, prefix: this.prefix });
        return {
            ...fromTmp,
            type: "empty-directory",
            release: () => this.cleanup(fromTmp.path, opts.keep),
            invalidate: () => Promise.resolve(),
            transient: opts.keep === false,
            provenance: `created with tmp, keep = ${opts.keep}`,
        };
    }
github codechecks / monorepo / packages / utils / src / tmpDir.ts View on Github external
export async function createTmpDir(): Promise {
  const { path: tmpPathDir } = await dir({ prefix: SHARED_PREFIX });
  debug(`Created tmp dir:`, tmpPathDir);

  return tmpPathDir;
}
github pubpub / pubpub / workers / tasks / import / tmpDirectory.js View on Github external
export const buildTmpDirectory = async (sourceFiles) => {
	const filesMap = new Map();
	const tmpDir = await tmp.dir();
	await Promise.all(
		sourceFiles.map(async (sourceFile) => {
			const { url, localPath } = sourceFile;
			const tmpPath = path.join(tmpDir.path, localPath);
			await ensureDir(path.dirname(tmpPath));
			const tmpFile = await streamS3UrlToFile(url, tmpPath);
			filesMap.set(localPath, tmpFile);
		}),
	);
	return {
		getTmpPathByLocalPath: (localPath) => filesMap.get(localPath),
		tmpDir: tmpDir,
	};
};
github getstation / electron-chrome-extension / src / browser / cx-fetcher / download-provider.ts View on Github external
async downloadById(extensionId: IExtension['id']) {
    const tempDir = await dir({ prefix: 'ecx-', unsafeCleanup: true });

    this.downloads.set(extensionId, tempDir);

    const path = await downloadById(extensionId, tempDir.path, extensionId);

    return {
      id: extensionId,
      location: new Location(path),
    };
  }

tmp-promise

The tmp package with promises support and disposers.

MIT
Latest version published 2 years ago

Package Health Score

70 / 100
Full package analysis