currentactivity 1.0.1 → 1.0.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.
- package/README.md +3 -0
- package/build/index.js +13 -6
- package/package.json +2 -2
- package/src/index.ts +17 -5
package/README.md
CHANGED
package/build/index.js
CHANGED
|
@@ -136,9 +136,10 @@ function printAll() {
|
|
|
136
136
|
if (stackId != undefined) {
|
|
137
137
|
const stackLines = windowLines.filter((v) => {
|
|
138
138
|
const s = v.trim();
|
|
139
|
-
return s.startsWith("*")
|
|
139
|
+
return ((s.startsWith("*") || s.startsWith("Activity #")) &&
|
|
140
|
+
s.indexOf(stackId) > 0);
|
|
140
141
|
});
|
|
141
|
-
const stacks = stackLines.map((v) => v.trim().split(" ")
|
|
142
|
+
const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
|
|
142
143
|
if (stacks[0] != currentActivity) {
|
|
143
144
|
stacks.shift();
|
|
144
145
|
}
|
|
@@ -298,8 +299,13 @@ function findLines(lines, target) {
|
|
|
298
299
|
return result;
|
|
299
300
|
}
|
|
300
301
|
function findFirstLines(lines, target) {
|
|
301
|
-
|
|
302
|
-
|
|
302
|
+
const matchedLines = findLines(lines, target);
|
|
303
|
+
for (const line of matchedLines) {
|
|
304
|
+
if (line.content.indexOf("null") < 0) {
|
|
305
|
+
return line.content;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return undefined;
|
|
303
309
|
}
|
|
304
310
|
function findFirstLineIndex(lines, target) {
|
|
305
311
|
const firstLine = findLines(lines, target).at(0);
|
|
@@ -417,9 +423,10 @@ function printCurrentActivityStack() {
|
|
|
417
423
|
if (stackId != undefined) {
|
|
418
424
|
const stackLines = windowLines.filter((v) => {
|
|
419
425
|
const s = v.trim();
|
|
420
|
-
return s.startsWith("*")
|
|
426
|
+
return ((s.startsWith("*") || s.startsWith("Activity #")) &&
|
|
427
|
+
s.indexOf(stackId) > 0);
|
|
421
428
|
});
|
|
422
|
-
const stacks = stackLines.map((v) => v.trim().split(" ")
|
|
429
|
+
const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
|
|
423
430
|
if (stacks[0] != currentActivity) {
|
|
424
431
|
stacks.shift();
|
|
425
432
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "currentactivity",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"description": "A command line tool to display the current activity for android.",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -38,4 +38,4 @@
|
|
|
38
38
|
"publishConfig": {
|
|
39
39
|
"access": "public"
|
|
40
40
|
}
|
|
41
|
-
}
|
|
41
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -155,9 +155,12 @@ async function printAll() {
|
|
|
155
155
|
if (stackId != undefined) {
|
|
156
156
|
const stackLines = windowLines.filter((v) => {
|
|
157
157
|
const s = v.trim();
|
|
158
|
-
return
|
|
158
|
+
return (
|
|
159
|
+
(s.startsWith("*") || s.startsWith("Activity #")) &&
|
|
160
|
+
s.indexOf(stackId) > 0
|
|
161
|
+
);
|
|
159
162
|
});
|
|
160
|
-
const stacks = stackLines.map((v) => v.trim().split(" ")
|
|
163
|
+
const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
|
|
161
164
|
if (stacks[0] != currentActivity) {
|
|
162
165
|
stacks.shift();
|
|
163
166
|
}
|
|
@@ -352,7 +355,13 @@ function findFirstLines(
|
|
|
352
355
|
lines: Array<string>,
|
|
353
356
|
target: string
|
|
354
357
|
): string | undefined {
|
|
355
|
-
|
|
358
|
+
const matchedLines = findLines(lines, target);
|
|
359
|
+
for (const line of matchedLines) {
|
|
360
|
+
if (line.content.indexOf("null") < 0) {
|
|
361
|
+
return line.content;
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
return undefined;
|
|
356
365
|
}
|
|
357
366
|
|
|
358
367
|
function findFirstLineIndex(lines: Array<string>, target: string): number {
|
|
@@ -495,9 +504,12 @@ async function printCurrentActivityStack() {
|
|
|
495
504
|
if (stackId != undefined) {
|
|
496
505
|
const stackLines = windowLines.filter((v) => {
|
|
497
506
|
const s = v.trim();
|
|
498
|
-
return
|
|
507
|
+
return (
|
|
508
|
+
(s.startsWith("*") || s.startsWith("Activity #")) &&
|
|
509
|
+
s.indexOf(stackId) > 0
|
|
510
|
+
);
|
|
499
511
|
});
|
|
500
|
-
const stacks = stackLines.map((v) => v.trim().split(" ")
|
|
512
|
+
const stacks = stackLines.map((v) => v.trim().split(" ").last(1));
|
|
501
513
|
if (stacks[0] != currentActivity) {
|
|
502
514
|
stacks.shift();
|
|
503
515
|
}
|