ipanel-rnapp-ajb-base 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/local-dev.js
CHANGED
|
@@ -3,6 +3,60 @@
|
|
|
3
3
|
const fs = require("fs");
|
|
4
4
|
const path = require("path");
|
|
5
5
|
|
|
6
|
+
// stat = fs.stat;
|
|
7
|
+
/*
|
|
8
|
+
* 复制目录中的所有文件包括子目录
|
|
9
|
+
* @param{ String } 需要复制的目录
|
|
10
|
+
* @param{ String } 复制到指定的目录
|
|
11
|
+
*/
|
|
12
|
+
var copy = function (src, dst) {
|
|
13
|
+
// 读取目录中的所有文件/目录
|
|
14
|
+
fs.readdir(src, function (err, paths) {
|
|
15
|
+
if (err) {
|
|
16
|
+
throw err;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
paths.forEach(function (path) {
|
|
20
|
+
var _src = src + "/" + path,
|
|
21
|
+
_dst = dst + "/" + path,
|
|
22
|
+
readable,
|
|
23
|
+
writable;
|
|
24
|
+
|
|
25
|
+
fs.stat(_src, function (err, st) {
|
|
26
|
+
if (err) {
|
|
27
|
+
throw err;
|
|
28
|
+
}
|
|
29
|
+
// 判断是否为文件
|
|
30
|
+
if (st.isFile()) {
|
|
31
|
+
// 创建读取流
|
|
32
|
+
readable = fs.createReadStream(_src);
|
|
33
|
+
// 创建写入流
|
|
34
|
+
writable = fs.createWriteStream(_dst);
|
|
35
|
+
// 通过管道来传输流
|
|
36
|
+
readable.pipe(writable);
|
|
37
|
+
}
|
|
38
|
+
// 如果是目录则递归调用自身
|
|
39
|
+
else if (st.isDirectory()) {
|
|
40
|
+
exists(_src, _dst, copy);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
// 在复制目录前需要判断该目录是否存在,不存在需要先创建目录
|
|
47
|
+
var exists = function (src, dst, callback) {
|
|
48
|
+
fs.exists(dst, function (exists) {
|
|
49
|
+
// 已存在
|
|
50
|
+
if (exists) {
|
|
51
|
+
// callback(src, dst);
|
|
52
|
+
} else {
|
|
53
|
+
fs.mkdir(dst, function () {
|
|
54
|
+
callback(src, dst);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
|
|
6
60
|
(function () {
|
|
7
61
|
console.log("ipanel_rnapp_ajb_base local_dev=====");
|
|
8
62
|
|
|
@@ -15,6 +69,23 @@ const path = require("path");
|
|
|
15
69
|
// 重写.local_dev/polyfill.js
|
|
16
70
|
fs.writeFileSync(
|
|
17
71
|
path.resolve(__dirname, "../app/.local_dev/polyfill.js"),
|
|
18
|
-
fs.readFileSync(path.resolve(__dirname, "
|
|
72
|
+
fs.readFileSync(path.resolve(__dirname, "../tmpl/polyfill.js")).toString()
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
fs.copyFile(
|
|
76
|
+
path.resolve(__dirname, "../tmpl/index.android.js"),
|
|
77
|
+
"../../index.android.js",
|
|
78
|
+
(err) => {
|
|
79
|
+
if (err) throw err;
|
|
80
|
+
console.log("index.android.js文件拷贝成功!");
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
fs.copyFile(
|
|
84
|
+
path.resolve(__dirname, "../tmpl/index.ios.js"),
|
|
85
|
+
"../../index.ios.js",
|
|
86
|
+
(err) => {
|
|
87
|
+
if (err) throw err;
|
|
88
|
+
console.log("index.ios.js文件拷贝成功!");
|
|
89
|
+
}
|
|
19
90
|
);
|
|
20
91
|
})();
|
package/package.json
CHANGED
|
File without changes
|