How to use the tmp.dir 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 npm / fs-vacuum / test / no-entries-with-purge.js View on Github external
test('xXx setup xXx', function (t) {
  mkdtemp(TEMP_OPTIONS, function (er, tmpdir) {
    t.ifError(er, 'temp directory exists')

    testBase = path.resolve(tmpdir, SHORT_PATH)
    testPath = path.resolve(tmpdir, LONG_PATH)

    mkdirp(testPath, function (er) {
      t.ifError(er, 'made test path')

      writeFileSync(path.resolve(tmpdir, FIRST_FILE), new Buffer("c'est vraiment joli"))
      writeFileSync(path.resolve(tmpdir, SECOND_FILE), new Buffer('oui oui'))
      t.end()
    })
  })
})
github socialtables / graphql-test-generator / gqlTestExtraction.js View on Github external
function gqlTestExtraction({ entry, output, schemaLocation, overwriteFiles, importLocation }) {
	tmp.dir({ unsafeCleanup: true}, (err, graphqlOutput, cleanup) => {
		fs.readdir(entry, (err, files) => {
			errorExit(err);
			let finishedCount = 0;
			files.forEach(file => {
				fs.stat(path.join(entry, file), (err, stat) => {
					errorExit(err);
					if (stat.isFile() && file.includes(".js")) {
						fs.readFile(path.join(entry, file), "utf8", (err, data) => {
							errorExit(err);
							const { queriesWritten } = gqlExtract({
								source: data,
								filePath: graphqlOutput
							});
							if (queriesWritten.size) {
								queriesWritten.forEach((query, queryName) => {
										errorExit(err);
github digidem / osm-p2p-syncfile / test / replicate.js View on Github external
test('replicate media + osm-p2p to syncfile', function (t) {
  tmp.dir(function (err, dir, cleanup) {
    t.error(err)

    var mfeed = multifeed(ram, { valueEncoding: 'json' })
    var media = blob()
    var syncfile
    var node = { type: 'node', lat: 1, lon: 2 }

    mfeed.writer('default', function (err, w) {
      t.error(err)
      w.append(node, function (err) {
        t.error(err)
        setup()
      })
    })

    function setup () {
github feup-infolab / dendro / src / utils / uploader.js View on Github external
req.busboy.on("file", function (fieldname, file, filename)
            {
                ++filesCounter;
                let fileSize = 0;

                tmp.dir({dir: Config.tempFilesDir}, function _tempDirCreated (err, tempFolderPath)
                {
                    if (isNull(err))
                    {
                        let newFileLocalPath = path.join(tempFolderPath, filename);
                        fstream = fs.createWriteStream(newFileLocalPath);

                        fstream.on("error", function ()
                        {
                            return callback(1, "Error saving file from request into temporary file");
                        });

                        file.on("data", function (data)
                        {
                            fileSize += data.length;
                        });
github mattdesl / budo / lib / tmpdir.js View on Github external
module.exports = function(cb) {
  tmp.dir({
      mode: '0755',
      prefix: 'budo-'
    },
    function(err, filepath) {
      if (!err) {
        process.on('exit', remove)
        process.on('SIGINT', exit)
        process.on('uncaughtException', exit)
        log.debug('temp directory created at', filepath)
      }

      cb(err, filepath)

      function remove(err) {
        try {
          rimraf.sync(filepath)
github yarnpkg / berry / packages / yarnpkg-fslib / sources / index.ts View on Github external
return new Promise((resolve, reject) => {
        tmp.dir({unsafeCleanup: true}, (err, path, cleanup) => {
          if (err) {
            reject(err);
          } else {
            Promise.resolve(npath.toPortablePath(path)).then(cb).then(result => {
              cleanup();
              resolve(result);
            }, error => {
              cleanup();
              reject(error);
            });
          }
        });
      });
    }
github processing / p5.js-web-editor / server / routes / uploader.api.routes.js View on Github external
const preuploadMiddleware = (req, res, next) => {
  req.imagesFolder = uuid.v4();
  if (!tmpDir) {
    tmpDir = tmp.dir((err, path) => {
      tmpDir = path;
      next();
    });
  } else {
    next();
  }
};
github pandawing / node-run-yo / lib / tmp-dir-promised.js View on Github external
return new Promise(function (resolve, reject) {
    tmp.setGracefulCleanup();
    tmp.dir(value, function (err, dirPath, cleanupCallback) {
      if (err) {
        reject(new errors.Error('tmp.dir', err));
        return;
      }
      resolve({
        dirPath: dirPath,
        cleanupCallback: cleanupCallback
      });
    });
  });
};
github artis-auxilium / laravel-node-queue / Commands / laravelConfig.js View on Github external
return new Promise(function promisePrepareTmpFolder(resolve, reject) {
    tmp.dir({
      prefix: 'laravel_queue-',
      unsafeCleanup: true
    }, function tmpDirCallback(err, name) {
      if (err) {
        return reject(err);
      }
      fs.mkdir(name + '/Config-laravel')
        .then(function tmpdirOk() {
          resolve(name + '/Config-laravel');
        });

    });
  });
};