How to use the os.tmpDir function in os

To help you get started, we’ve selected a few os 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 Ideolys / carbone / lib / params.js View on Github external
var os = require('os');

// manage node 0.8 / 0.10 differences
var nodeVersion = process.versions.node.split('.');
var tmpDir = (parseInt(nodeVersion[0], 10) === 0 && parseInt(nodeVersion[1], 10) < 10) ? os.tmpDir() : os.tmpdir();

module.exports  = {
  /* Temp directory */
  tempPath         : tmpDir,
  /* Template path */
  templatePath     : process.cwd(),
  /* Number of LibreOffice + Python factory to start by default. One factory = 2 threads */
  factories        : 1,
  /* If LibreOffice fails to convert one document, how many times we re-try to convert this file? */
  attempts         : 3,
  /* If true, it will start LibreOffice + Python factory immediately (true by default if the carbone server is used). 
     If false, it will start LibreOffice + Python factory only when at least one document conversion is needed.*/
  startFactory     : false,
  /* The method helper.getUID() add this prefix in the uid */
  uidPrefix        : 'c',
  /* If multiple factories are used, the pipe name is generated automatically to avoid conflicts */
github ngageoint / geopackage-js / lib / db / sqliteAdapter.js View on Github external
} catch (err) {
                console.log('error', err);
                return reject(err);
              }
            });
          });
        } else {
          db = new Database(filePath);
          var adapter = new Adapter(db);
          adapter.filePath = filePath;
          resolve(adapter);
        }
      } else if (filePath) {
        // write this byte array to a file then open it
        var byteArray = filePath;
        var tmpPath = path.join(os.tmpDir(), Date.now() + '.gpkg');
        return fs.writeFile(tmpPath, byteArray, function(err) {
          db = new Database(tmpPath);
          // verify that this is an actual database
          try {
            var applicationId = db.pragma('application_id');
            db.pragma('journal_mode = WAL');
          } catch (err) {
            console.log('error', err);
            return reject(err);
          }
          var adapter = new Adapter(db);
          adapter.filePath = tmpPath;
          resolve(adapter);
        });
      } else {
        console.log('create in memory');
github mozilla / goggles.mozilla.org / app.js View on Github external
idwmoURL: env.get("ID_WMO_URL"),
    clientId: env.get("ID_WMO_CLIENT_ID"),
    clientIdLib: env.get("ID_WMO_CLIENT_ID_LIB"),
    publishwmoURL: env.get("PUBLISH_WMO_URL")
  });
});

// intercept webxray's publication dialog - HTML part
app.get("/gogglesnotice.js", function(req, res) {
  res.render("gogglesnotice.js", {
    hostname: env.get("APP_HOSTNAME")
  });
});

var optimize = (node_env !== "development"),
    tmpDir = path.join( require("os").tmpDir(), "mozilla.webmaker.org");

app.use(lessMiddleWare({
  once: optimize,
  debug: !optimize,
  dest: tmpDir,
  src: WWW_ROOT,
  compress: true,
  yuicompress: optimize,
  optimization: optimize ? 0 : 2
}));

// serve static content, resolved in this order:
app.use(static(tmpDir));
app.use(static(path.join(__dirname, "public")));
app.use(static(path.join(__dirname, "webxray/static-files")));
["src", "test", "js"].forEach(function(dir) {
github jaruba / PowderPlayer / node_modules / peerflix / node_modules / torrent-stream / index.js View on Github external
var fileStream = require('./lib/file-stream');
var piece = require('./lib/piece');

var MAX_REQUESTS = 5;
var CHOKE_TIMEOUT = 5000;
var REQUEST_TIMEOUT = 30000;
var SPEED_THRESHOLD = 3 * piece.BLOCK_SIZE;
var DEFAULT_PORT = 6881;

var BAD_PIECE_STRIKES_MAX = 3;
var BAD_PIECE_STRIKES_DURATION = 120000; // 2 minutes

var RECHOKE_INTERVAL = 10000;
var RECHOKE_OPTIMISTIC_DURATION = 2;

var TMP = fs.existsSync('/tmp') ? '/tmp' : os.tmpDir();

var noop = function() {};

var sha1 = function(data) {
	return crypto.createHash('sha1').update(data).digest('hex');
};

var thruthy = function() {
	return true;
};

var falsy = function() {
	return false;
};

var toNumber = function(val) {
github lucasfcosta / learnyounode-pt-br / exercises / faa_isso_modular / exercise.js View on Github external
var fs            = require('fs')
  , path          = require('path')
  , os            = require('os')
  , exercise      = require('workshopper-exercise')()
  , filecheck     = require('workshopper-exercise/filecheck')
  , execute       = require('workshopper-exercise/execute')
  , comparestdout = require('workshopper-exercise/comparestdout')
  , wrappedexec   = require('workshopper-wrappedexec')
  , after         = require('after')
  , rimraf        = require('rimraf')
  , verify        = require('./verify')
  , files         = require('../filtered_ls/file-list')

  , testDir       = path.join(os.tmpDir(), '_learnyounode_' + process.pid)


// checks that the submission file actually exists
exercise = filecheck(exercise)

// execute the solution and submission in parallel with spawn()
exercise = execute(exercise)

// compare stdout of solution and submission
exercise = comparestdout(exercise)

// wrap up the child process in a phantom wrapper that can
// mess with the global environment and inspect execution
exercise = wrappedexec(exercise)

// modules we want run just prior to the submission in the
github hapijs / hapi / test / cli.js View on Github external
{
                    port: 0,
                    labels: ['api', 'nasty', 'test']
                },
                {
                    host: 'localhost',
                    port: 0,
                    labels: ['api', 'nice']
                }
            ],
            plugins: {
                './--loaded': {}
            }
        };

        var configPath = Hoek.uniqueFilename(Os.tmpDir());
        var hapiPath = Path.join(__dirname, '..', 'bin', 'hapi');
        var modulePath = Path.join(__dirname, 'plugins');

        Fs.writeFileSync(configPath, JSON.stringify(manifest));

        var hapi = ChildProcess.spawn('node', [hapiPath, '-c', configPath, '-p', modulePath]);

        hapi.stdout.on('data', function (data) {

            expect(data.toString()).to.equal('loaded\n');
            hapi.kill();
            Fs.unlinkSync(configPath);

            done();
        });
github rain1017 / memdb / test / env.js View on Github external
exports.startCluster = function(shardIds, configOverrideFunc){
    var newConfigPath = configPath;
    if(typeof(configOverrideFunc) === 'function'){
        var newConfig = utils.clone(config);
        configOverrideFunc(newConfig);
        newConfigPath = path.join(os.tmpDir(), 'memdb-test.conf.json');
        fs.writeFileSync(newConfigPath, JSON.stringify(newConfig));
    }

    var args = [memdbClusterPath, 'start', '--conf=' + newConfigPath];
    if(shardIds){
        if(!Array.isArray(shardIds)){
            shardIds = [shardIds];
        }
        shardIds.forEach(function(shardId){
            args.push('--shard=' + shardId);
        });
    }

    var output = child_process.execFileSync(process.execPath, args).toString();
    logger.info(output.toString());
};
github samuelbetio / storyofmylife / bower_components / istanbul / lib / store / tmp.js View on Github external
function makeTempDir() {
    var dir = path.join(os.tmpDir ? os.tmpDir() : (process.env.TMPDIR || '/tmp'), 'ts' + new Date().getTime());
    mkdirp.sync(dir);
    return dir;
}
/**
github codio / tutorial_nodeschool_learnyounode / problems / http_file_server / setup.js View on Github external
module.exports = function (run) {
  var file      = path.join(os.tmpDir(), 'learnyounode_' + process.pid + '.txt')
    , trackFile = path.join(os.tmpDir(), 'learnyounode_' + process.pid + '.json')
    , outputA   = through()
    , outputB   = through()

  function error (url, out, err) {
    out.write('Error connecting to ' + url + ': ' + err.message)
    out.end()
  }

  setTimeout(function () {
    hyperquest.get('http://localhost:8000')
      .on('error', error.bind(null, 'http://localhost:8000', outputA))
      .pipe(outputA)
    if (!run) {
      hyperquest.get('http://localhost:8001')
        .on('error', error.bind(null, 'http://localhost:8001', outputB))
github rolfn / node-gitlab-hook / gitlabhook.js View on Github external
self.logger.info('Executed: ' + self.cmdshell + ' ' + fname);
          process.stdout.write(stdout);
        }
        process.stderr.write(stderr);
        execute(path, ++idx);
      });
    });
  }

  var cmds = getCmds(self.tasks, map, repo);

  if (cmds.length > 0) {

    self.logger.info('cmds: ' + inspect(cmds) + '\n');

    Tmp.mkdir({dir:Os.tmpDir(), prefix:'gitlabhook.'}, function(err, path) {
      if (err) {
        self.logger.error(err);
        return;
      }
      self.path = path;
      self.logger.info('Tempdir: ' + path);
      var i = 0;
      execute(path, i);
    });

  } else {
    self.logger.info('No related commands for repository "' + repo + '"');
  }
}