How to use the tmp.tmpdir 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 njpanderson / push / src / ProviderBase.js View on Github external
mkDirRecursive(dir, root, fnDir, dirSeparator = '/') {
		let baseDir, recursiveDir, dirList;

		if (dir === root) {
			// Resolve the promise immediately as the root directory must exist
			return Promise.resolve();
		}

		if (dir.startsWith(root) || dir.includes(tmp.tmpdir)) {
			// Dir starts with the root path, or is part of the temporary file path
			baseDir = utils.trimSeparators(dir.replace(root, ''), dirSeparator);
			recursiveDir = baseDir.split(dirSeparator);
			dirList = [];

			// First, create a directory list for the Promise loop to iterate over
			recursiveDir.reduce((acc, current) => {
				let pathname = (acc === '' ? current : (acc + dirSeparator + current));

				if (pathname !== '') {
					dirList.push(
						utils.addTrailingSeperator(root, dirSeparator) + pathname
					);
				}

				return pathname;
github benjamingr / tmp-promise / index.js View on Github external
module.exports.withDir = async function withDir(fn, options) {
  const { path, cleanup } = await module.exports.dir(options);
  try {
    return await fn({ path });
  } finally {
    await cleanup();
  }
};


// name generation
module.exports.tmpNameSync = tmp.tmpNameSync;
module.exports.tmpName = promisify(tmp.tmpName);

module.exports.tmpdir = tmp.tmpdir;

module.exports.setGracefulCleanup = tmp.setGracefulCleanup;
github bower / bower / test / core / resolvers / resolver.js View on Github external
.then(function(dir) {
                    var dirname;
                    var osTempDir;

                    expect(dir).to.be.a('string');
                    expect(fs.existsSync(dir)).to.be(true);

                    dirname = path.dirname(dir);
                    osTempDir = path.resolve(tmp.tmpdir);

                    expect(dir.indexOf(osTempDir)).to.be(0);
                    expect(dir.indexOf(config.tmp)).to.be(0);

                    expect(path.basename(dirname)).to.equal('bower');
                    expect(path.dirname(path.dirname(dirname))).to.equal(
                        osTempDir
                    );
                    next();
                })
                .done();
github hw2-archive / upt / test / core / resolvers / resolver.js View on Github external
.then(function (dir) {
                var dirname;
                var osTempDir;

                expect(dir).to.be.a('string');
                expect(fs.existsSync(dir)).to.be(true);

                dirname = path.dirname(dir);
                osTempDir = path.resolve(tmp.tmpdir);

                expect(dir.indexOf(osTempDir)).to.be(0);
                expect(dir.indexOf(defaultConfig.tmp)).to.be(0);

                expect(path.basename(dirname)).to.equal('upt');
                expect(path.dirname(path.dirname(dirname))).to.equal(osTempDir);
                next();
            })
            .done();
github ChangemakerStudios / Papercut / src / Papercut.Desktop / main.js View on Github external
function setupOutputRedirection() {
    const fs = require('fs');
    const tmp = require('tmp');
    const papercutTmpDir = path.join(tmp.tmpdir, 'Papercut');

    let debugPapercut = process.debugPapercut;
    if (!debugPapercut) {
        tmp.setGracefulCleanup();
    }

    if (!fs.existsSync(papercutTmpDir)){
        fs.mkdirSync(papercutTmpDir)
    }

    let tempFile = tmp.fileSync(
        {
            prefix: 'Output-',
            postfix: '.log',
            discardDescriptor: true,
            dir: papercutTmpDir,