UNPKG

678 BJavaScriptView Raw
1var
2 fs = require('fs'),
3 tmp = require('../lib/tmp');
4
5function _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
16module.exports.out = function (str, cb) {
17 _writeSync(process.stdout, str, cb);
18};
19
20module.exports.err = function (str, cb) {
21 _writeSync(process.stderr, str, cb);
22};
23
24module.exports.exit = function () {
25 process.exit(0);
26};
27
28var type = process.argv[2];
29module.exports.tmpFunction = (type == 'file') ? tmp.file : tmp.dir;
30
31var arg = (process.argv[3] && parseInt(process.argv[3], 10) === 1) ? true : false;
32module.exports.arg = arg;