cocos2d-cli 2.1.1 → 2.1.3
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.
|
@@ -3,12 +3,14 @@ import { takeScreenshot } from '../lib/screenshot-core.js';
|
|
|
3
3
|
export async function run(args) {
|
|
4
4
|
const jsonFilePath = args[0];
|
|
5
5
|
if (!jsonFilePath) {
|
|
6
|
-
console.log(JSON.stringify({ error: '用法: cocos2d-cli screenshot <json文件> [--width <宽度>] [--height <高度>] [--output
|
|
6
|
+
console.log(JSON.stringify({ error: '用法: cocos2d-cli screenshot <json文件> [--width <宽度>] [--height <高度>] [--output <输出目录>] [--debug-bounds] [--wait <毫秒>]' }));
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
let width = 750;
|
|
10
10
|
let height = 1334;
|
|
11
|
-
let
|
|
11
|
+
let outputDir = process.cwd();
|
|
12
|
+
let debugBounds = false;
|
|
13
|
+
let waitTime = 3000;
|
|
12
14
|
for (let i = 1; i < args.length; i++) {
|
|
13
15
|
const arg = args[i];
|
|
14
16
|
if (arg === '--width' && args[i + 1]) {
|
|
@@ -19,8 +21,15 @@ export async function run(args) {
|
|
|
19
21
|
height = parseInt(args[i + 1]);
|
|
20
22
|
i++;
|
|
21
23
|
}
|
|
22
|
-
else if (arg === '--output' && args[i + 1]) {
|
|
23
|
-
|
|
24
|
+
else if ((arg === '--output' || arg === '-o') && args[i + 1]) {
|
|
25
|
+
outputDir = args[i + 1];
|
|
26
|
+
i++;
|
|
27
|
+
}
|
|
28
|
+
else if (arg === '--debug-bounds') {
|
|
29
|
+
debugBounds = true;
|
|
30
|
+
}
|
|
31
|
+
else if (arg === '--wait' && args[i + 1]) {
|
|
32
|
+
waitTime = parseInt(args[i + 1]);
|
|
24
33
|
i++;
|
|
25
34
|
}
|
|
26
35
|
}
|
|
@@ -28,12 +37,14 @@ export async function run(args) {
|
|
|
28
37
|
const { screenshotPath, logs } = await takeScreenshot({
|
|
29
38
|
jsonPath: jsonFilePath,
|
|
30
39
|
viewport: { width, height },
|
|
31
|
-
outputDir
|
|
40
|
+
outputDir,
|
|
32
41
|
fullPage: true,
|
|
42
|
+
debugBounds,
|
|
33
43
|
timeout: 30000,
|
|
34
|
-
waitTime
|
|
44
|
+
waitTime
|
|
35
45
|
});
|
|
36
|
-
|
|
46
|
+
const filename = path.basename(screenshotPath);
|
|
47
|
+
console.log(JSON.stringify({ success: true, filename }));
|
|
37
48
|
}
|
|
38
49
|
catch (err) {
|
|
39
50
|
console.log(JSON.stringify({ error: err.message }));
|