How to use the tmp.tmpNameSync function in tmp

To help you get started, we’ve selected a few tmp 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 juttle / juttle / test / adapters / file / write.spec.js View on Github external
'use strict';

var _ = require('underscore');
var expect = require('chai').expect;
var tmp = require('tmp');
var fs = require('fs');
var juttle_test_utils = require('../../runtime/specs/juttle-test-utils');
var check_juttle = juttle_test_utils.check_juttle;
var expect_to_fail = juttle_test_utils.expect_to_fail;
var run_read_file_juttle = require('./utils').run_read_file_juttle;

var tmp_file = tmp.tmpNameSync();

var symmetricalFormats = {
    json: 'json',
    jsonl: 'jsonl',
    csv: 'csv'
};

describe('write file adapter tests', function () {

    afterEach(function() {
        try {
            fs.unlinkSync(tmp_file);
        } catch(err) { /* file not written -- ignore */ }
    });

    it('fails when you do not provide a file to write', function() {
github oclif / oclif / test / run.js View on Github external
function build(type, features) {
  let options = ''
  if (features === 'everything') options = '--options=yarn,typescript,eslint,mocha'
  if (features === 'typescript') options = '--options=yarn,typescript'
  if (features === 'mocha') options = '--options=yarn,mocha'
  let dir = CI ? tmp.tmpNameSync() : path.join(__dirname, '../tmp')
  dir = path.join(dir, type, features)
  sh.rm('-rf', dir)
  generate(`${type} ${dir} --defaults ${options}`)
  sh.cd(dir)
  // sh.exec('git add .')
  // sh.exec('git commit -nm init')
  // sh.exec('git checkout -B origin/master')
  process.env = npmPath.env({env: process.env})
}
github DevExpress / testcafe / src / utils / temp-directory / index.js View on Github external
async _createNewTmpDir () {
        this.path = tmp.tmpNameSync({ dir: TempDirectory.TEMP_DIRECTORIES_ROOT, prefix: this.namePrefix + '-' });

        await makeDir(this.path);

        this.lockFile = new LockFile(this.path);

        this.lockFile.init();
    }
github mehcode / atom-updater / src / main.js View on Github external
async function installVersion(version) {
  console.log("");
  console.log("\x1b[1;37m[*] Downloading version v%s...\x1b[0m", version);
  var filename = tmp.tmpNameSync();
  var file = fs.createWriteStream(filename);
  var atomLatest = "atom-amd64.deb"
  var cmd = "dpkg"
  console.log("\x1b[1;37m[*] Checking OS... v%s...\x1b[0m", version);
  await new Promise(function(resolve) {
    fs.stat("/etc/redhat-release", function(err0, stat0) {
      if (err0) {
        fs.stat("/etc/debian_version", function(err1, stat1) {
          if (err1) {
            return console.log("Not supported")
          }
          cmd = "dpkg"
          atomLatest = "atom-amd64.deb"
          resolve()
        })
      } else {
github yarnpkg / berry / packages / yarnpkg-core / sources / tgzUtils.ts View on Github external
export async function convertToZip(tgz: Buffer, opts: ExtractBufferOptions) {
  return await extractArchiveTo(tgz, new ZipFS(NodeFS.toPortablePath(tmpNameSync()), {create: true}), opts);
}
github codemod-js / codemod / packages / cli / src / resolvers / NetworkResolver.ts View on Github external
async resolve(source: string): Promise {
    const response = await get(source, { followRedirect: true });

    if (response.statusCode !== 200) {
      throw new NetworkLoadError(response);
    }

    const filename = tmp({ postfix: '.js' });
    await writeFile(filename, response.body);
    return filename;
  }
}
github itchio / itch / appsrcts / util / sandbox / linux.ts View on Github external
async function sudoRunScript(lines: string[]): Promise {
  const contents = lines.join("\n");
  const tmpObjName = tmp.tmpNameSync();
  await sf.writeFile(tmpObjName, contents);
  await sf.chmod(tmpObjName, 0o777);

  const res = await spawn.exec({ command: "pkexec", args: [tmpObjName] });

  await sf.wipe(tmpObjName);

  if (res.code !== 0) {
    throw new Error(`pkexec failed with code ${res.code}, stderr = ${res.err}`);
  }

  return { out: res.out };
}
github stanfieldr / ghetto-skype / src / main.js View on Github external
tmpWindow.webContents.session.once('will-download', (event, downloadItem) => {
		imageCache[url] = file = {
			path: require('tmp').tmpNameSync() + '.' + require('mime').extension(downloadItem.getMimeType()),
			complete: false
		};

		downloadItem.setSavePath(file.path);
		downloadItem.once('done', () => {
			tmpWindow.destroy();
			tmpWindow = null;

			electron.shell.openItem(file.path);

			file.complete = true;
		});
	});
github itchio / itch / appsrc / util / sandbox / linux.ts View on Github external
async function sudoRunScript(lines: string[]): Promise {
  const contents = lines.join("\n");
  const tmpObjName = tmp.tmpNameSync();
  await sf.writeFile(tmpObjName, contents);
  await sf.chmod(tmpObjName, 0o777);

  const res = await spawn.exec({ command: "pkexec", args: [tmpObjName] });

  await sf.wipe(tmpObjName);

  if (res.code !== 0) {
    throw new Error(`pkexec failed with code ${res.code}, stderr = ${res.err}`);
  }

  return { out: res.out };
}
github mkloubert / vscode-helpers / src / fs / index.ts View on Github external
export function tempFileSync(
    action: (file: string) => TResult, opts?: TempFileOptions
): TResult {
    opts = normalizeTempFileOptions(opts);

    let tempFile: TempFilePath = false;
    try {
        tempFile = TMP.tmpNameSync(
            toTmpSimpleOptions(opts)
        );

        return action(tempFile);
    } finally {
        tryUnlinkTempFile(tempFile, opts);
    }
}