lottie-helper 1.0.5 → 1.0.6
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/dist/bundle.min.js +1 -1
- package/package.json +1 -1
- package/readme.md +19 -0
- package/rollup.config.controller.js +0 -31
- package/rollup.config.js +0 -36
- package/src/controller/animateControl.js +0 -43
- package/src/controller/index.js +0 -41
- package/src/html/index.html +0 -21
- package/src/index.js +0 -71
- package/src/json/jsonAnimate.json +0 -1
- package/src/loadJson.js +0 -86
- package/src/utils/index.js +0 -25
package/src/loadJson.js
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
import fs from "fs";
|
2
|
-
import path from "path";
|
3
|
-
|
4
|
-
// 读取指定json文件
|
5
|
-
export const loadJson = async (fileName) => {
|
6
|
-
try {
|
7
|
-
console.log("loadJson running...");
|
8
|
-
// TODO 容错,多种方式不局限于json文件引入
|
9
|
-
return new Promise((resolve, reject) => {
|
10
|
-
const filePath = path.join(process.cwd(), fileName)
|
11
|
-
fs.readFile(filePath, "utf-8", (err, data) => {
|
12
|
-
if (err) return reject(err);
|
13
|
-
resolve(data);
|
14
|
-
});
|
15
|
-
});
|
16
|
-
//完成
|
17
|
-
} catch (err) {
|
18
|
-
Promise.reject(err);
|
19
|
-
}
|
20
|
-
};
|
21
|
-
|
22
|
-
// 写入约定的json文件
|
23
|
-
export const writeJson = async (jsonData) => {
|
24
|
-
try {
|
25
|
-
console.log("writeJson running...");
|
26
|
-
return new Promise((resolve, reject) => {
|
27
|
-
fs.writeFile(`src/json/jsonAnimate.json`, jsonData, "utf-8", (err) => {
|
28
|
-
if (err) return reject(err);
|
29
|
-
resolve("write done");
|
30
|
-
});
|
31
|
-
});
|
32
|
-
//完成
|
33
|
-
} catch (err) {
|
34
|
-
Promise.reject(err);
|
35
|
-
}
|
36
|
-
};
|
37
|
-
|
38
|
-
// 读取指定HTML文件
|
39
|
-
export const loadHTML = async (fileName = "index.html") => {
|
40
|
-
try {
|
41
|
-
console.log("loadHTML running...");
|
42
|
-
return new Promise((resolve, reject) => {
|
43
|
-
const filePath = path.join(process.cwd(), fileName)
|
44
|
-
fs.readFile(filePath, "utf-8", (err, data) => {
|
45
|
-
if (err) return reject(err);
|
46
|
-
resolve(data);
|
47
|
-
});
|
48
|
-
});
|
49
|
-
//完成
|
50
|
-
} catch (err) {
|
51
|
-
Promise.reject(err);
|
52
|
-
}
|
53
|
-
};
|
54
|
-
|
55
|
-
// 写入约定的html文件
|
56
|
-
export const writeHTML = async (filePathName, HTMLStr) => {
|
57
|
-
try {
|
58
|
-
console.log("writeHTML running...");
|
59
|
-
return new Promise((resolve, reject) => {
|
60
|
-
const filePath = path.join(process.cwd(), filePathName)
|
61
|
-
fs.writeFile(filePath, HTMLStr, "utf-8", (err) => {
|
62
|
-
if (err) return reject(err);
|
63
|
-
resolve("write done");
|
64
|
-
});
|
65
|
-
});
|
66
|
-
//完成
|
67
|
-
} catch (err) {
|
68
|
-
Promise.reject(err);
|
69
|
-
}
|
70
|
-
};
|
71
|
-
|
72
|
-
// 读取指定JS文件(bundle)
|
73
|
-
export const loadJs = async (fileName) => {
|
74
|
-
try {
|
75
|
-
console.log("loadJs running...");
|
76
|
-
return new Promise((resolve, reject) => {
|
77
|
-
fs.readFile(`./${fileName}`, "utf-8", (err, data) => {
|
78
|
-
if (err) return reject(err);
|
79
|
-
resolve(data);
|
80
|
-
});
|
81
|
-
});
|
82
|
-
//完成
|
83
|
-
} catch (err) {
|
84
|
-
Promise.reject(err);
|
85
|
-
}
|
86
|
-
};
|
package/src/utils/index.js
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
const childProcess = require("child_process");
|
2
|
-
|
3
|
-
// node中子进程执行shell脚本
|
4
|
-
export const nodeRunShell = (shell) => {
|
5
|
-
return new Promise((resolve, reject) => {
|
6
|
-
childProcess.exec(
|
7
|
-
shell,
|
8
|
-
(error, stdout, stderr) => {
|
9
|
-
console.log("exec:");
|
10
|
-
console.log("error", error);
|
11
|
-
console.log("stdout", stdout);
|
12
|
-
console.log("stderr", stderr);
|
13
|
-
if (!error) {
|
14
|
-
console.log("shell 执行成功");
|
15
|
-
resolve("shell 执行成功");
|
16
|
-
// 成功
|
17
|
-
} else {
|
18
|
-
// 失败
|
19
|
-
console.log("shell 执行失败");
|
20
|
-
reject('shell 执行失败')
|
21
|
-
}
|
22
|
-
}
|
23
|
-
);
|
24
|
-
})
|
25
|
-
}
|