Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit c859ef5

Browse files
committed
Added author property to snippets
1 parent 40185fa commit c859ef5

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
**latest release**
77
#### Features
88
- Debug functionalities *(for easier bug reporting)*
9+
- Snippet class:
10+
- (+) Author
911
#### Improvements
1012
- Path resolvement
1113
- Debug options storing
@@ -14,6 +16,7 @@
1416
#### Patches
1517
- Error while reading stored files
1618
- Migration even if there were no changes made
19+
- Debug snippet logging
1720

1821
---
1922

lib/snippet.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use babel';
22

33
import Util from './util.js';
4+
const os = require('os');
45

56
export default class Snippet {
67

@@ -10,6 +11,7 @@ export default class Snippet {
1011
lang = '';
1112
uid = Date.now().toString();
1213
version = undefined;
14+
author = os.userInfo().username;
1315

1416
constructor(state) {
1517
if(typeof state === 'object') {
@@ -31,6 +33,9 @@ export default class Snippet {
3133
if(Util.isset(state.version,'string')) {
3234
this.version = state.version;
3335
}
36+
if(Util.isset(state.author,'string')) {
37+
this.author = state.author;
38+
}
3439
}
3540
}
3641

@@ -42,7 +47,8 @@ export default class Snippet {
4247
'content':this.getContent(),
4348
'lang':this.getLang(),
4449
'uid':this.getUID(),
45-
'version':this.getVersion()
50+
'version':this.getVersion(),
51+
'author':this.getAuthor()
4652
};
4753
}
4854

@@ -74,6 +80,10 @@ export default class Snippet {
7480
return this.version;
7581
}
7682

83+
getAuthor() {
84+
return this.author;
85+
}
86+
7787
setTitle(newtitle) {
7888
this.title = newtitle;
7989
}
@@ -97,4 +107,8 @@ export default class Snippet {
97107
setUID(newuid) {
98108
this.uid = newuid;
99109
}
110+
111+
setAuthor(newauthor) {
112+
this.author = newauthor;
113+
}
100114
}

lib/storage.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { dirname } from 'path';
44
import Snippet from './snippet.js';
55
import Util from './util.js';
66
const fs = require('fs');
7-
// const os = require('os');
7+
8+
const lastSnippetUpdate = '1.1.8';
89

910
export default class Storage {
1011

@@ -174,8 +175,8 @@ export default class Storage {
174175
_this.backup(current);
175176

176177
var snippet = new Snippet(JSON.parse(_this.retrieveFile(current)));
177-
var res = Util.compareVersions('1.0.0',snippet.getVersion());
178-
if(res === '1.0.0' || res === undefined) {
178+
var res = Util.compareVersions(lastSnippetUpdate,snippet.getVersion());
179+
if(res === lastSnippetUpdate || res === undefined) {
179180
snippet.setVersion(Util.getPackageVersion());
180181
snippet.setUID(Util.generateUID({
181182
unique: true,

0 commit comments

Comments
 (0)