-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (48 loc) · 1.26 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
'use strict';
var cofy = require('cofy');
function cofyFs(){
var fs = require('fs');
var methods = [
'readFile','close','open','read','write',
'rename','truncate','ftruncate','rmdir','fdatasync',
'fsync','mkdir','readdir','fstat','lstat','stat','readlink',
'symlink','link','unlink','fchmod','chmod','fchown','chown',
'utimes','futimes','writeFile','appendFile','watch','watchFile',
'unwatchFile','realpath','createReadStream',
'createWriteStream'
];
fs.$exists = cofy.fn(fs.exists ,false ,fs);
return cofy.object(fs,true,methods);
}
function cofyChildProcess(){
var cp = require('child_process');
cp.$exec = function(cmd, opt){
return function(done){
var r = cp.exec(cmd , opt , function(e, stdout, stderr){
done(e, stdout,stderr , r);
});
};
};
cp.$execFile = function(file,args, opt){
return function(done){
var r = cp.execFile(file,args, opt,function(e, stdout, stderr){
done(e, stdout,stderr , r);
});
};
};
return cp;
}
function cofyDns(){
return cofy.object(require('dns'));
}
function cofyZlib(){
var zlib = require('zlib');
var methods = ['deflate', 'deflateRaw','gzip','gunzip','inflate','inflateRaw','unzip'];
cofy.object(zlib,true,methods);
}
module.exports = function(){
cofyFs();
cofyChildProcess();
cofyDns();
cofyZlib();
};