mm_expand 1.5.6 → 1.5.7
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/demo/test/image/logo.png +0 -0
- package/demo/test/local.json +4 -0
- package/demo/test3/image/logo.png +0 -0
- package/demo/test3/local.json +4 -0
- package/demo/test4/image/logo.png +0 -0
- package/demo/test4/local.json +4 -0
- package/demo/test5/local.json +4 -0
- package/demo/test5/local2.json +4 -0
- package/index.js +35 -3
- package/package.json +2 -1
- package/test.js +18 -9
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/index.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* @author <a href="http://qww.elins.cn">邱文武</a>
|
|
4
4
|
* @version 1.2
|
|
5
5
|
*/
|
|
6
|
-
const JSON5 = require('json5')
|
|
6
|
+
const JSON5 = require('json5');
|
|
7
|
+
var ncp = require('ncp').ncp;
|
|
7
8
|
const {
|
|
8
9
|
j2xParser,
|
|
9
10
|
parse
|
|
@@ -1383,8 +1384,9 @@ if (typeof($) === "undefined") {
|
|
|
1383
1384
|
* @param {String} dir 文件路径
|
|
1384
1385
|
*/
|
|
1385
1386
|
String.prototype.addDir = function(dirbase) {
|
|
1386
|
-
var d = (this + '').fullname();
|
|
1387
|
-
|
|
1387
|
+
var d = (this + '').fullname(dirbase);
|
|
1388
|
+
|
|
1389
|
+
if (d.indexOf('.') !== -1) {
|
|
1388
1390
|
d = d.dirname()
|
|
1389
1391
|
}
|
|
1390
1392
|
var arr = d.split(slash);
|
|
@@ -1405,6 +1407,15 @@ if (typeof($) === "undefined") {
|
|
|
1405
1407
|
String.prototype.copyFile = function(file) {
|
|
1406
1408
|
return copyFileSync(this.fullname(), file.fullname());
|
|
1407
1409
|
};
|
|
1410
|
+
|
|
1411
|
+
/**
|
|
1412
|
+
* @description 复制目录
|
|
1413
|
+
* @param {String} file 保存路径
|
|
1414
|
+
* @return {Boolean} 复制成功返回true, 失败返回false
|
|
1415
|
+
*/
|
|
1416
|
+
String.prototype.copyDir = function(file, func) {
|
|
1417
|
+
return ncp(this.fullname(), file.fullname(), func);
|
|
1418
|
+
};
|
|
1408
1419
|
})();
|
|
1409
1420
|
|
|
1410
1421
|
/* == 数组原型函数 == */
|
|
@@ -2254,6 +2265,14 @@ if (typeof($) === "undefined") {
|
|
|
2254
2265
|
getDir(list, dir.fullname(), keyword);
|
|
2255
2266
|
return list;
|
|
2256
2267
|
};
|
|
2268
|
+
/**
|
|
2269
|
+
* 复制目录
|
|
2270
|
+
* @param {String} sourcePath 源路径
|
|
2271
|
+
* @param {String} targetPath 目标路径
|
|
2272
|
+
*/
|
|
2273
|
+
Dir.prototype.copy = function(sourcePath, targetPath, func) {
|
|
2274
|
+
ncp(sourcePath.fullname(), targetPath.fullname(), func);
|
|
2275
|
+
}
|
|
2257
2276
|
}
|
|
2258
2277
|
/**
|
|
2259
2278
|
* 文件类函数
|
|
@@ -2319,6 +2338,19 @@ if (typeof($) === "undefined") {
|
|
|
2319
2338
|
return false;
|
|
2320
2339
|
}
|
|
2321
2340
|
}
|
|
2341
|
+
/**
|
|
2342
|
+
* @description 加载文件
|
|
2343
|
+
* @param {String} file 文件路径
|
|
2344
|
+
* @param {String} data 编码方式
|
|
2345
|
+
* @return {Boolean} 保存成功返回true,否则返回false
|
|
2346
|
+
*/
|
|
2347
|
+
File.prototype.copy = function(sourcePath, targetPath) {
|
|
2348
|
+
try {
|
|
2349
|
+
copyFileSync(sourcePath.fullname(), targetPath.fullname());
|
|
2350
|
+
} catch (err) {
|
|
2351
|
+
console.error(err);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2322
2354
|
}
|
|
2323
2355
|
$.file = new File();
|
|
2324
2356
|
$.dir = new Dir();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mm_expand",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "这是超级美眉原型函数拓展模块,更有利于对string、array、object的操作,避免出错,简化业务逻辑。",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"fast-xml-parser": "^3.21.1",
|
|
33
33
|
"json5": "^2.2.3",
|
|
34
|
+
"ncp": "^2.0.0",
|
|
34
35
|
"pinyinlite": "^1.2.1"
|
|
35
36
|
}
|
|
36
37
|
}
|
package/test.js
CHANGED
|
@@ -1,18 +1,27 @@
|
|
|
1
1
|
require('./index.js');
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
// 测试复制目录
|
|
4
|
+
// "./demo/test".copyDir("./demo/test3"); // 方法1
|
|
5
|
+
// $.dir.copy("./demo/test", "./demo/test4"); // 方法2
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
// 测试复制文件
|
|
8
|
+
"./demo/test5/".addDir();
|
|
9
|
+
"./demo/test/local.json".copyDir("./demo/test5/local.json"); // 方法1
|
|
10
|
+
$.dir.copy("./demo/test/local.json", "./demo/test5/local2.json"); // 方法2
|
|
7
11
|
|
|
8
|
-
var
|
|
9
|
-
console.log(time2);
|
|
12
|
+
// var timeStr = "1970-01-01 00:00:00";
|
|
10
13
|
|
|
11
|
-
var
|
|
12
|
-
console.log(
|
|
14
|
+
// var time = timeStr.toTime();
|
|
15
|
+
// console.log(time);
|
|
13
16
|
|
|
14
|
-
var
|
|
15
|
-
console.log(
|
|
17
|
+
// var time2 = timeStr.addDays(367);
|
|
18
|
+
// console.log(time2);
|
|
19
|
+
|
|
20
|
+
// var time3 = timeStr.addSeconds(60);
|
|
21
|
+
// console.log(time3.toStr("yyyy-MM-dd hh:mm:ss"));
|
|
22
|
+
|
|
23
|
+
// var time4 = timeStr.addSeconds(60, "yyyy-MM-dd hh:mm:ss");
|
|
24
|
+
// console.log(time4);
|
|
16
25
|
|
|
17
26
|
// "./中文/的".addDir(__dirname);
|
|
18
27
|
// "./中文/test.json".saveJson({ name: "123" });
|