diff options
author | Stefan Malzner <stefan@adlk.io> | 2017-11-03 23:22:38 +0100 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2017-11-03 23:22:38 +0100 |
commit | a54c87be1ce629cf13a5bfb9c2ba26958e0e4e74 (patch) | |
tree | da5535da9fd3af1dee6ad706bead7b8e4263468b | |
parent | Reset linux shortcuts to Ctrl (diff) | |
download | ferdium-app-a54c87be1ce629cf13a5bfb9c2ba26958e0e4e74.tar.gz ferdium-app-a54c87be1ce629cf13a5bfb9c2ba26958e0e4e74.tar.zst ferdium-app-a54c87be1ce629cf13a5bfb9c2ba26958e0e4e74.zip |
Parse recipe author string
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | src/models/Recipe.js | 16 | ||||
-rw-r--r-- | yarn.lock | 10 |
3 files changed, 25 insertions, 2 deletions
diff --git a/package.json b/package.json index 1c0aad789..fc0954e94 100644 --- a/package.json +++ b/package.json | |||
@@ -27,6 +27,7 @@ | |||
27 | "license": "Apache-2.0", | 27 | "license": "Apache-2.0", |
28 | "dependencies": { | 28 | "dependencies": { |
29 | "@paulcbetts/system-idle-time": "^1.0.4", | 29 | "@paulcbetts/system-idle-time": "^1.0.4", |
30 | "address-rfc2822": "^2.0.1", | ||
30 | "auto-launch": "https://github.com/meetfranz/node-auto-launch.git", | 31 | "auto-launch": "https://github.com/meetfranz/node-auto-launch.git", |
31 | "babel-polyfill": "^6.23.0", | 32 | "babel-polyfill": "^6.23.0", |
32 | "babel-runtime": "^6.23.0", | 33 | "babel-runtime": "^6.23.0", |
diff --git a/src/models/Recipe.js b/src/models/Recipe.js index 43a3450b1..4b613a40c 100644 --- a/src/models/Recipe.js +++ b/src/models/Recipe.js | |||
@@ -1,7 +1,8 @@ | |||
1 | import emailParser from 'address-rfc2822'; | ||
2 | |||
1 | export default class Recipe { | 3 | export default class Recipe { |
2 | id = ''; | 4 | id = ''; |
3 | name = ''; | 5 | name = ''; |
4 | author = ''; | ||
5 | description = ''; | 6 | description = ''; |
6 | version = '1.0'; | 7 | version = '1.0'; |
7 | path = ''; | 8 | path = ''; |
@@ -30,7 +31,7 @@ export default class Recipe { | |||
30 | 31 | ||
31 | this.id = data.id || this.id; | 32 | this.id = data.id || this.id; |
32 | this.name = data.name || this.name; | 33 | this.name = data.name || this.name; |
33 | this.author = data.author || this.author; | 34 | this.rawAuthor = data.author || this.author; |
34 | this.description = data.description || this.description; | 35 | this.description = data.description || this.description; |
35 | this.version = data.version || this.version; | 36 | this.version = data.version || this.version; |
36 | this.path = data.path; | 37 | this.path = data.path; |
@@ -49,4 +50,15 @@ export default class Recipe { | |||
49 | 50 | ||
50 | this.message = data.config.message || this.message; | 51 | this.message = data.config.message || this.message; |
51 | } | 52 | } |
53 | |||
54 | get author() { | ||
55 | try { | ||
56 | const addresses = emailParser.parse(this.rawAuthor); | ||
57 | return addresses.map(a => ({ email: a.address, name: a.phrase })); | ||
58 | } catch (err) { | ||
59 | console.warn(`Not a valid author for ${this.name}`); | ||
60 | } | ||
61 | |||
62 | return []; | ||
63 | } | ||
52 | } | 64 | } |
@@ -80,6 +80,12 @@ acorn@^5.1.1: | |||
80 | version "5.1.2" | 80 | version "5.1.2" |
81 | resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" | 81 | resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.1.2.tgz#911cb53e036807cf0fa778dc5d370fbd864246d7" |
82 | 82 | ||
83 | address-rfc2822@^2.0.1: | ||
84 | version "2.0.1" | ||
85 | resolved "https://registry.yarnpkg.com/address-rfc2822/-/address-rfc2822-2.0.1.tgz#1a1bdb942b5e20e2c1ba5d5f396d5824ff7ae6ea" | ||
86 | dependencies: | ||
87 | email-addresses "^3.0.0" | ||
88 | |||
83 | after@0.8.2: | 89 | after@0.8.2: |
84 | version "0.8.2" | 90 | version "0.8.2" |
85 | resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" | 91 | resolved "https://registry.yarnpkg.com/after/-/after-0.8.2.tgz#fedb394f9f0e02aa9768e702bda23b505fae7e1f" |
@@ -2049,6 +2055,10 @@ electron@^1.7.9: | |||
2049 | electron-download "^3.0.1" | 2055 | electron-download "^3.0.1" |
2050 | extract-zip "^1.0.3" | 2056 | extract-zip "^1.0.3" |
2051 | 2057 | ||
2058 | email-addresses@^3.0.0: | ||
2059 | version "3.0.1" | ||
2060 | resolved "https://registry.yarnpkg.com/email-addresses/-/email-addresses-3.0.1.tgz#c1fc20c189e7f96d4012d375db5feaccdd24391c" | ||
2061 | |||
2052 | emojis-list@^2.0.0: | 2062 | emojis-list@^2.0.0: |
2053 | version "2.1.0" | 2063 | version "2.1.0" |
2054 | resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" | 2064 | resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" |