How to use the tempy.file function in tempy

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 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 DefinitelyTyped / DefinitelyTyped / types / tempy / tempy-tests.ts View on Github external
import { directory, file, root } from "tempy";

//

const tempDir2: string = directory();

const tempFile: string = file();
const pngFile: string = file({ extension: "png" });

const fileWithName: string = file({ name: "afile.txt" });

const tmpRoot: string = root;
github DefinitelyTyped / DefinitelyTyped / types / tempy / tempy-tests.ts View on Github external
import { directory, file, root } from "tempy";

//

const tempDir2: string = directory();

const tempFile: string = file();
const pngFile: string = file({ extension: "png" });

const fileWithName: string = file({ name: "afile.txt" });

const tmpRoot: string = root;
github thammin / node-bpg / test / decoderSpec.js View on Github external
map(files, file => {
      const temp = tempy.file({ extension: 'png' });
      return decode(file, temp).then(() => temp);
    })
    .map(file => {
github feramhq / transity / scripts / transactions / hypovereinsbank.js View on Github external
async function getTransactions (options = {}) {
  const daysAgo = new Date()
  daysAgo.setDate(daysAgo.getDate() - options.numberOfDays)
  const {
    startDate = daysAgo,
    endDate = new Date(),
    username,
    password,
    shallShowBrowser = false,
  } = options

  const nightmare = new Nightmare({show: shallShowBrowser})
  const baseUrl = 'https://my.hypovereinsbank.de'
  const filePathTemp = tempy.file({name: 'hypovereinsbank-transactions.csv'})
  const log = process.env.NODE_DEBUG
    ? console.warn
    : () => {}

  const url = `${baseUrl}/login?view=/de/login.jsp`
  log(`Open ${url}`)
  await nightmare
    .goto(url)
    .wait('#loginPanel')


  log('Log in')
  await nightmare
    .insert('#loginPanel #username', username)
    .insert('#loginPanel #px2', password)
    .click('#loginCommandButton')
github feramhq / transity / scripts / transactions / dkb.js View on Github external
async function getTransactions (options = {}) {
  const daysAgo = new Date()
  daysAgo.setDate(daysAgo.getDate() - options.numberOfDays)
  const {
    startDate = daysAgo,
    endDate = new Date(),
    username,
    password,
    shallShowBrowser = false,
  } = options

  const nightmare = new Nightmare({show: shallShowBrowser})
  const baseUrl = 'https://www.dkb.de'
  const filePathTemp = tempy.file({name: 'dkb-transactions.csv'})
  const log = process.env.NODE_DEBUG
    ? console.warn
    : () => {}

  const loginUrl = `${baseUrl}/banking`
  log(`Open ${loginUrl}`)
  await nightmare
    .goto(loginUrl)
    .wait('#login')


  log('Log in')
  await nightmare
    .insert('#loginInputSelector', username)
    .insert('#pinInputSelector', password)
    .click('#buttonlogin')
github addyosmani / critical / lib / file-helper.js View on Github external
.then(() => {
                const filepath = tempy.file({extension: 'html'});
                file.path = filepath;
                file.path = path.join(folder, path.basename(filepath));
                file.base = folder;
                file.contents = Buffer.from(opts.html);
                debug(file);
                gc.addFile(filepath);
                return fs.outputFile(filepath, file.contents).then(() => {
                    return file;
                });
            });
    }
github IMA-WorldHealth / bhima / server / lib / backup.js View on Github external
function backup(filename) {
  const file = filename || tmp.file({ extension : '.sql' });

  debug(`#backup() beginning backup routine.`);

  return mysqldump(file)
    .then(() => xz(file))
    .then(upload);
}

tempy

Get a random temporary file or directory path

MIT
Latest version published 1 year ago

Package Health Score

70 / 100
Full package analysis