-
Notifications
You must be signed in to change notification settings - Fork 238
/
utils.js
40 lines (33 loc) · 930 Bytes
/
utils.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
"use strict";
var fs = require("fs"),
path = require("path"),
Wind = require("../src/wind"),
_ = Wind._;
var copySync = function (src, dest) {
var content = fs.readFileSync(src, "utf8");
fs.writeFileSync(dest, content, "utf8");
}
var rmdirSync = function (dir) {
var files = fs.readdirSync(dir);
for (var i = 0; i < files.length; i++) {
var filepath = path.join(dir, files[i]);
var stat = fs.statSync(filepath);
if (stat.isFile()) {
fs.unlinkSync(filepath);
} else {
rmdirSync(filepath);
}
}
fs.rmdirSync(dir);
}
var stdout = function () {
process.stdout.write(_.format.apply(this, arguments));
}
var stderr = function () {
process.stderr.write(_.format.apply(this, arguments));
}
exports.copySync = copySync;
exports.rmdirSync = rmdirSync;
exports.stdout = stdout;
exports.stderr = stderr;
exports.Wind = Wind;