Skip to content

Commit 2b81eea

Browse files
author
Ilya Radchenko
committed
Cleanup cachier
Remove unused spawn code, general cleanup
1 parent 74b7e98 commit 2b81eea

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

lib/cachier.js

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1+
'use strict';
12

2-
var spawn = require('child_process').spawn
3-
, path = require('path')
4-
, fs = require('fs-extra')
3+
var path = require('path');
4+
var fs = require('fs-extra');
55

6-
module.exports = cachier
7-
8-
function safespawn() {
9-
var c = spawn.apply(null, arguments)
10-
c.on('error', function (err) {
11-
// suppress node errors
12-
})
13-
return c
14-
}
6+
module.exports = cachier;
157

168
function cachier(base) {
179
function child(sub) {
18-
return cachier(path.join(base, sub))
10+
return cachier(path.join(base, sub));
1911
}
12+
2013
child.get = function (key, dest, done) {
2114
if (arguments.length === 2) {
22-
done = dest
23-
dest = key
24-
key = ''
15+
done = dest;
16+
dest = key;
17+
key = '';
2518
}
26-
copy(path.join(base, key), dest, done)
27-
}
19+
20+
copy(path.join(base, key), dest, done);
21+
};
22+
2823
child.update = function (key, dest, done) {
2924
if (arguments.length === 2) {
30-
done = dest
31-
dest = key
32-
key = ''
25+
done = dest;
26+
dest = key;
27+
key = '';
3328
}
34-
copy(dest, path.join(base, key), done)
29+
30+
copy(dest, path.join(base, key), done);
3531
}
36-
child.base = base
37-
return child
32+
33+
child.base = base;
34+
35+
return child;
3836
}
3937

4038
function copy(from, to, done) {
4139
fs.exists(from, function (exists) {
42-
if (!exists) return done(new Error('Source does not exist: ' + from))
40+
if (!exists) {
41+
return done(new Error('Source does not exist: ' + from));
42+
}
43+
4344
fs.remove(to, function () {
4445
fs.mkdirp(path.dirname(to), function () {
4546
fs.copy(from, to, function (err) {
46-
return done(err && new Error('Failed to retrieve cached code: ' + err))
47-
})
48-
})
49-
})
50-
})
47+
return done(err && new Error('Failed to retrieve cached code: ' + err));
48+
});
49+
});
50+
});
51+
});
5152
}
52-

0 commit comments

Comments
 (0)