Skip to content

Commit 94a629f

Browse files
authored
Merge pull request #26 from perryrh0dan/dev
Dev
2 parents 640a40f + 2cc35a8 commit 94a629f

File tree

8 files changed

+94
-39
lines changed

8 files changed

+94
-39
lines changed

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"name": "Launch Program",
1212
"program": "${workspaceFolder}/dist/cli.js",
13-
"args": ["l", "canceled"]
13+
"args": ["b", "2"]
1414
},
1515
{
1616
"type": "node",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@perryrh0dan/taskline",
33
"productName": "Taskline",
4-
"version": "1.3.4",
4+
"version": "1.4.0",
55
"description": "Tasks, boards & notes for the command-line habitat",
66
"repository": "https://github.com/perryrh0dan/taskline",
77
"license": "MIT",

readme.md

+14-1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Come over to [Gitter](https://gitter.im/taskline/community?source=orgpage) or [T
7474
- Possibility to cancel tasks
7575
- Possibility to rearrange item ids
7676
- Timetracking for tasks
77+
- Multilanguage support
7778

7879
### Coming
7980

@@ -602,7 +603,17 @@ Run the build script from '/scripts/build.sh'
602603

603604
### Publish
604605

605-
After
606+
#### Npm
607+
608+
100% automated;
609+
610+
#### Snapcraft
611+
612+
``` bash
613+
snapcraft login
614+
615+
snapcraft push --release=stable taskline_1.3.4_multi.snap
616+
```
606617

607618
## Team
608619

@@ -611,3 +622,5 @@ After
611622
## License
612623

613624
[MIT](https://github.com/perryrh0dan/taskline/blob/master/license.md)
625+
626+
This repository was generated by [charon](https://github.com/perryrh0dan/charon)

snapcraft.sh renamed to scripts/snapcraft.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/bin/bash
22
set -e #stop on error
3+
echo 'Build Snap Package...'
34

45
# Check if temp already exists if yes delete
5-
bash -c '[ -d temp ] && rm -r temp'
6+
if [ -d temp ]; then rm -r temp; fi;
67

78
# Creating a temp directory for the build and navigate in
89
echo 'Creating temp directory'
@@ -57,7 +58,8 @@ rm ./gulpfile.js
5758

5859
# Build Snap
5960
echo 'Build snap'
60-
sudo snapcraft cleanbuild
61+
sudo snapcraft clean
62+
sudo snapcraft
6163

6264
# Copy snap to main directory
6365
echo 'Copy snap to main directory'
@@ -68,5 +70,5 @@ find ./ -iname '*.snap' -exec cp {} ../ \;
6870
# Navigate out and delete temp directory
6971
echo 'Delete temp directory'
7072
cd ..
71-
sudo rm -r ./temp
73+
# sudo rm -r ./temp
7274

snapcraft.yaml

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: taskline
2-
version: '1.3.4'
2+
version: '1.4.0'
33
summary: Tasks, boards & notes for the command-line habitat
44
description: |
55
By utilizing a simple and minimal usage syntax, that requires a flat learning curve, Taskline enables you
@@ -24,12 +24,13 @@ description: |
2424
* Multiple storage modules.
2525
* Save date on your local machine at `~/.taskline/storage` or
2626
* Use the firestore module to sync your tasks across all your devices.
27+
* Timetracking for tasks
28+
* Multilanguage support
2729
* Lightweight & fast
28-
* Data written atomically to storage
30+
* Data written automically to storage
2931
* Custom storage location
3032
* Progress overview
3133
* Simple & minimal usage syntax
32-
* Update notifications
3334
* Configurable through `~/.taskline.json`
3435
3536
More informations under https://github.com/perryrh0dan/taskline.
@@ -42,6 +43,13 @@ architectures:
4243
- amd64
4344
- i386
4445

46+
parts:
47+
taskline:
48+
plugin: nodejs
49+
nodejs-version: 12.16.1
50+
nodejs-package-manager: npm
51+
source: .
52+
4553
apps:
4654
taskline:
4755
command: tl
@@ -50,10 +58,3 @@ apps:
5058
- network
5159
- network-control
5260
- x11
53-
54-
parts:
55-
taskline:
56-
plugin: nodejs
57-
node-engine: 12.16.1
58-
node-package-manager: npm
59-
source: .

src/renderer.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ export class Renderer {
315315

316316
let passedTime;
317317
if (item instanceof Task && item.passedTime > 0) {
318-
passedTime = this.getPassedTime(item.passedTime);
318+
passedTime = this.getPassedTime(item.getRealPassedTime());
319319
}
320320

321321
const star = this.getStar(item);

src/task.ts

+21-7
Original file line numberDiff line numberDiff line change
@@ -79,28 +79,36 @@ export class Task extends Item {
7979
}
8080

8181
public get passedTime(): number {
82-
if(this._lastStartTime != 0) {
83-
return this._passedTime + (new Date().getTime() - this._lastStartTime);
84-
}
8582
return this._passedTime;
8683
}
8784

85+
public getRealPassedTime(): number {
86+
if(this.lastStartTime != 0) {
87+
return this.passedTime + (new Date().getTime() - this.lastStartTime);
88+
}
89+
return this.passedTime;
90+
}
91+
8892
public get lastStartTime(): number {
8993
return this._lastStartTime;
9094
}
9195

9296
public begin(): void {
97+
debugger;
9398
const now: Date = new Date();
9499

95100
// check if task is started or paused
96101
if(this.inProgress == true) {
97-
this._passedTime += now.getTime() - this._lastStartTime;
102+
// just for backwards compatibility
103+
if (this.lastStartTime != 0) {
104+
this._passedTime += now.getTime() - this.lastStartTime;
105+
}
98106
this._lastStartTime = 0;
99107
} else {
100108
this._lastStartTime = now.getTime();
101109
}
102110

103-
this.inProgress = !this._inProgress;
111+
this.inProgress = !this.inProgress;
104112
this.isComplete = false;
105113
this.isCanceled = false;
106114
}
@@ -109,7 +117,10 @@ export class Task extends Item {
109117
const now: Date = new Date();
110118

111119
if(this.inProgress == true) {
112-
this._passedTime += now.getTime() - this._lastStartTime;
120+
// just for backwards compatibility
121+
if (this.lastStartTime != 0) {
122+
this._passedTime += now.getTime() - this.lastStartTime;
123+
}
113124
this._lastStartTime = 0;
114125
}
115126

@@ -122,7 +133,10 @@ export class Task extends Item {
122133
const now: Date = new Date();
123134

124135
if(this.inProgress == true) {
125-
this._passedTime += now.getTime() - this._lastStartTime;
136+
// just for backwards compatibility
137+
if (this.lastStartTime != 0) {
138+
this._passedTime += now.getTime() - this.lastStartTime;
139+
}
126140
this._lastStartTime = 0;
127141
}
128142

test/begin.spec.ts

+40-15
Original file line numberDiff line numberDiff line change
@@ -64,49 +64,74 @@ describe('Test begin functionality', () => {
6464

6565
it('should begin one task', async() => {
6666
const now = new Date();
67+
const oldData: Array<Item> = await helper.getData([2]);
68+
const oldTask: Task = oldData[0] as Task;
69+
6770
await taskline.beginTasks('2');
71+
6872
const data: Array<Item> = await helper.getData([2]);
69-
expect((data[0] as Task).inProgress).toBe(true);
70-
expect((data[0] as Task).isCanceled).toBe(false);
71-
expect((data[0] as Task).isComplete).toBe(false);
72-
expect((data[0] as Task).lastStartTime).toBeGreaterThan(now.getTime());
73+
const task: Task = data[0] as Task;
74+
75+
expect(task.inProgress).toBe(true);
76+
expect(task.isCanceled).toBe(false);
77+
expect(task.isComplete).toBe(false);
78+
expect(task.lastStartTime).toBeGreaterThan(now.getTime());
79+
expect(task.passedTime).toBe(oldTask.passedTime);
7380
});
7481

7582
it('should pause one task', async() => {
83+
const now = new Date();
84+
const oldData: Array<Item> = await helper.getData([2]);
85+
const oldTask: Task = oldData[0] as Task;
86+
7687
await taskline.beginTasks('2');
88+
7789
const data: Array<Item> = await helper.getData([2]);
78-
expect((data[0] as Task).inProgress).toBe(false);
79-
expect((data[0] as Task).isCanceled).toBe(false);
80-
expect((data[0] as Task).isComplete).toBe(false);
81-
expect((data[0] as Task).passedTime).toBeGreaterThan(0);
82-
expect((data[0] as Task).lastStartTime).toBe(0);
90+
const task: Task = data[0] as Task;
91+
92+
expect(task.inProgress).toBe(false);
93+
expect(task.isCanceled).toBe(false);
94+
expect(task.isComplete).toBe(false);
95+
expect(task.passedTime).toBeGreaterThanOrEqual(oldTask.passedTime + now.getTime() - oldTask.lastStartTime);
96+
expect(task.lastStartTime).toBe(0);
8397
});
8498

8599
it('should continue one task', async() => {
86100
const now = new Date();
101+
const oldData: Array<Item> = await helper.getData([2]);
102+
const oldTask: Task = oldData[0] as Task;
103+
87104
await taskline.beginTasks('2');
105+
88106
const data: Array<Item> = await helper.getData([2]);
89-
expect((data[0] as Task).inProgress).toBe(true);
90-
expect((data[0] as Task).isCanceled).toBe(false);
91-
expect((data[0] as Task).isComplete).toBe(false);
92-
expect((data[0] as Task).passedTime).toBeGreaterThan(0);
93-
expect((data[0] as Task).lastStartTime).toBeGreaterThanOrEqual(
107+
const task: Task = data[0] as Task;
108+
109+
expect(task.inProgress).toBe(true);
110+
expect(task.isCanceled).toBe(false);
111+
expect(task.isComplete).toBe(false);
112+
expect(task.passedTime).toBe(oldTask.passedTime);
113+
expect(task.lastStartTime).toBeGreaterThanOrEqual(
94114
now.getTime()
95115
);
96116
});
97117

98118
it('should begin multiple tasks', async() => {
99119
const now = new Date();
120+
const oldData: Array<Item> = await helper.getData([2, 3]);
121+
100122
await taskline.beginTasks('2,3');
123+
101124
const data: Array<Item> = await helper.getData([2, 3]);
125+
102126
expect((data[0] as Task).inProgress).toBe(false);
103127
expect((data[0] as Task).isCanceled).toBe(false);
104128
expect((data[0] as Task).isComplete).toBe(false);
105-
expect((data[0] as Task).passedTime).toBeGreaterThan(0);
129+
expect((data[0] as Task).passedTime).toBeGreaterThanOrEqual((oldData[0] as Task).passedTime + now.getTime() - (oldData[0] as Task).lastStartTime);
106130
expect((data[0] as Task).lastStartTime).toBe(0);
107131
expect((data[1] as Task).inProgress).toBe(true);
108132
expect((data[1] as Task).isCanceled).toBe(false);
109133
expect((data[1] as Task).isComplete).toBe(false);
134+
expect((data[1] as Task).passedTime).toBe((oldData[1] as Task).passedTime);
110135
expect((data[1] as Task).lastStartTime).toBeGreaterThanOrEqual(
111136
now.getTime()
112137
);

0 commit comments

Comments
 (0)