Initial commit
[yaffs-website] / node_modules / tmp / test / spawn.js
1 var
2   fs = require('fs'),
3   tmp = require('../lib/tmp');
4
5 function _writeSync(stream, str, cb) {
6   var flushed = stream.write(str);
7   if (flushed) {
8     return cb(null);
9   }
10
11   stream.once('drain', function _flushed() {
12     cb(null);
13   });
14 }
15
16 module.exports.out = function (str, cb) {
17   _writeSync(process.stdout, str, cb);
18 };
19
20 module.exports.err = function (str, cb) {
21   _writeSync(process.stderr, str, cb);
22 };
23
24 module.exports.exit = function () {
25   process.exit(0);
26 };
27
28 var type = process.argv[2];
29 module.exports.tmpFunction = (type == 'file') ? tmp.file : tmp.dir;
30
31 var arg = (process.argv[3] && parseInt(process.argv[3], 10) === 1) ? true : false;
32 module.exports.arg = arg;