How to use tempy - 10 common examples

To help you get started, we’ve selected a few tempy 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 expo / expo-cli / packages / expo-cli / src / commands / eject / Eject.ts View on Github external
appJson.expo.entryPoint = EXPO_APP_ENTRY;
  }

  log('Writing app.json...');
  await fse.writeFile(path.resolve('app.json'), JSON.stringify(appJson, null, 2));
  log(chalk.green('Wrote to app.json, please update it manually in the future.'));

  // This is validated later...
  let defaultDependencies: any = {};
  let defaultDevDependencies: any = {};

  /**
   * Extract the template and copy it over
   */
  try {
    const tempDir = temporary.directory();
    await Exp.extractTemplateAppAsync(templateSpec, tempDir, appJson);
    fse.copySync(path.join(tempDir, 'ios'), path.join(projectRoot, 'ios'));
    fse.copySync(path.join(tempDir, 'android'), path.join(projectRoot, 'android'));
    const { dependencies, devDependencies } = JsonFile.read(path.join(tempDir, 'package.json'));
    defaultDependencies = ensureDependenciesMap(dependencies);
    defaultDevDependencies = devDependencies;
    log('Successfully copied template native code.');
  } catch (e) {
    log(chalk.red(e.message));
    log(chalk.red(`Eject failed, see above output for any issues.`));
    log(chalk.yellow('You may want to delete the `ios` and/or `android` directories.'));
    process.exit(1);
  }

  log(`Updating your package.json...`);
  if (!pkg.scripts) {
github typicode / husky / src / __tests__ / getConf.ts View on Github external
it('should support .huskyrc', (): void => {
    const tempDir = tempy.directory()
    fs.writeFileSync(
      path.join(tempDir, '.huskyrc'),
      JSON.stringify(testConf.husky)
    )

    expect(getConf(tempDir)).toEqual({ skipCI: true, foo: 'bar' })
  })
})
github GoogleChrome / workbox / test / workbox-build / node / generate-sw.js View on Github external
it(`should use defaults when all the required parameters are present, with 'globFollow' and  symlinks`, async function() {
      const outputDir = tempy.directory();
      const swDest = upath.join(outputDir, 'sw.js');
      const globDirectory = tempy.directory();

      await fse.ensureSymlink(GLOB_DIR, upath.join(globDirectory, 'link'));

      const options = Object.assign({}, BASE_OPTIONS, {
        globDirectory,
        globFollow: false,
        swDest,
      });

      const {count, filePaths, size, warnings} = await generateSW(options);
      expect(warnings).to.be.empty;
      expect(count).to.eql(4);
      expect(size).to.eql(2535);

      confirmDirectoryContains(outputDir, filePaths);
github sindresorhus / make-dir / test / sync.js View on Github external
test('dir exists', t => {
	const dir = makeDir.sync(tempy.directory());
	t.true(dir.length > 0);
	assertDirectory(t, dir);
});
github sindresorhus / make-dir / test / sync.js View on Github external
test('file exits', t => {
	const fp = tempy.file();
	fs.writeFileSync(fp, '');
	t.throws(() => {
		makeDir.sync(fp);
	}, {code: 'EEXIST'});
});
github GoogleChrome / workbox / test / workbox-build / node / generate-sw.js View on Github external
it(`should reject with a ValidationError when 'networkTimeoutSeconds' is used and handler is not 'NetworkFirst'`, async function() {
      const swDest = tempy.file({extension: 'js'});
      const runtimeCachingOptions = {
        networkTimeoutSeconds: 1,
      };
      const runtimeCaching = [{
        urlPattern: REGEXP_URL_PATTERN,
        handler: 'NetworkOnly',
        options: runtimeCachingOptions,
      }];
      const options = Object.assign({}, BASE_OPTIONS, {
        runtimeCaching,
        swDest,
      });

      try {
        await generateSW(options);
        throw new Error('Unexpected success.');
github Rowno / grunt-mocha-cli / test / lib.js View on Github external
test('save option', async t => {
  const outputPath = tempy.file()
  await mocha({
    files: [getFixturePath('pass.js')],
    save: outputPath,
    reporter: 'tap'
  })
  const output = await fs.readFile(outputPath, 'utf8')
  t.true(output.includes('# pass 1'), 'expect 1 pass')
})
github pfrazee / diff-file-tree / test / util.js View on Github external
module.exports.mockCyclical = function mockCyclical () {
  var sfs = new ScopedFS(tempy.directory())
  fs.mkdirSync(path.join(sfs.base, 'subdir'))
  fs.writeFileSync(path.join(sfs.base, 'subdir', 'foo.txt'), 'more content', 'utf8')
  fs.symlinkSync(sfs.base, path.join(sfs.base, 'subdir', 'symlink'))
  return sfs
}
github beakerbrowser / webdb / test / query-mutators.js View on Github external
async function def (fn) {
    const a = await DatArchive.create({localPath: tempy.directory()})
    await a.mkdir('/multi')
    const write = (path, record) => a.writeFile(path, JSON.stringify(record))
    await fn(write, a)
    return a
  }
  for (let i = 0; i < 10; i++) {

tempy

Get a random temporary file or directory path

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis