diff options
Diffstat (limited to 'src/models/Recipe.ts')
-rw-r--r-- | src/models/Recipe.ts | 67 |
1 files changed, 50 insertions, 17 deletions
diff --git a/src/models/Recipe.ts b/src/models/Recipe.ts index 859c75df0..e45977f24 100644 --- a/src/models/Recipe.ts +++ b/src/models/Recipe.ts | |||
@@ -1,10 +1,7 @@ | |||
1 | import semver from 'semver'; | 1 | import semver from 'semver'; |
2 | import { pathExistsSync } from 'fs-extra'; | 2 | import { pathExistsSync } from 'fs-extra'; |
3 | import { join } from 'path'; | 3 | import { join } from 'path'; |
4 | import { | 4 | import { ifUndefinedString, ifUndefinedBoolean } from '../jsUtils'; |
5 | ifUndefinedString, | ||
6 | ifUndefinedBoolean, | ||
7 | } from '../jsUtils'; | ||
8 | 5 | ||
9 | interface IRecipe { | 6 | interface IRecipe { |
10 | id: string; | 7 | id: string; |
@@ -75,7 +72,8 @@ export default class Recipe { | |||
75 | 72 | ||
76 | message: string = ''; | 73 | message: string = ''; |
77 | 74 | ||
78 | allowFavoritesDelineationInUnreadCount: boolean = DEFAULT_RECIPE_SETTINGS.allowFavoritesDelineationInUnreadCount; | 75 | allowFavoritesDelineationInUnreadCount: boolean = |
76 | DEFAULT_RECIPE_SETTINGS.allowFavoritesDelineationInUnreadCount; | ||
79 | 77 | ||
80 | disablewebsecurity: boolean = DEFAULT_RECIPE_SETTINGS.disablewebsecurity; | 78 | disablewebsecurity: boolean = DEFAULT_RECIPE_SETTINGS.disablewebsecurity; |
81 | 79 | ||
@@ -98,7 +96,9 @@ export default class Recipe { | |||
98 | } | 96 | } |
99 | 97 | ||
100 | if (!semver.valid(data.version)) { | 98 | if (!semver.valid(data.version)) { |
101 | throw new Error(`Version ${data.version} of recipe '${data.name}' is not a valid semver version`); | 99 | throw new Error( |
100 | `Version ${data.version} of recipe '${data.name}' is not a valid semver version`, | ||
101 | ); | ||
102 | } | 102 | } |
103 | 103 | ||
104 | // from the recipe | 104 | // from the recipe |
@@ -106,19 +106,52 @@ export default class Recipe { | |||
106 | this.name = ifUndefinedString(data.name, this.name); | 106 | this.name = ifUndefinedString(data.name, this.name); |
107 | this.version = ifUndefinedString(data.version, this.version); | 107 | this.version = ifUndefinedString(data.version, this.version); |
108 | this.aliases = data.aliases || this.aliases; | 108 | this.aliases = data.aliases || this.aliases; |
109 | this.serviceURL = ifUndefinedString(data.config.serviceURL, this.serviceURL); | 109 | this.serviceURL = ifUndefinedString( |
110 | this.hasDirectMessages = ifUndefinedBoolean(data.config.hasDirectMessages, this.hasDirectMessages); | 110 | data.config.serviceURL, |
111 | this.hasIndirectMessages = ifUndefinedBoolean(data.config.hasIndirectMessages, this.hasIndirectMessages); | 111 | this.serviceURL, |
112 | this.hasNotificationSound = ifUndefinedBoolean(data.config.hasNotificationSound, this.hasNotificationSound); | 112 | ); |
113 | this.hasDirectMessages = ifUndefinedBoolean( | ||
114 | data.config.hasDirectMessages, | ||
115 | this.hasDirectMessages, | ||
116 | ); | ||
117 | this.hasIndirectMessages = ifUndefinedBoolean( | ||
118 | data.config.hasIndirectMessages, | ||
119 | this.hasIndirectMessages, | ||
120 | ); | ||
121 | this.hasNotificationSound = ifUndefinedBoolean( | ||
122 | data.config.hasNotificationSound, | ||
123 | this.hasNotificationSound, | ||
124 | ); | ||
113 | this.hasTeamId = ifUndefinedBoolean(data.config.hasTeamId, this.hasTeamId); | 125 | this.hasTeamId = ifUndefinedBoolean(data.config.hasTeamId, this.hasTeamId); |
114 | this.hasCustomUrl = ifUndefinedBoolean(data.config.hasCustomUrl, this.hasCustomUrl); | 126 | this.hasCustomUrl = ifUndefinedBoolean( |
115 | this.hasHostedOption = ifUndefinedBoolean(data.config.hasHostedOption, this.hasHostedOption); | 127 | data.config.hasCustomUrl, |
116 | this.urlInputPrefix = ifUndefinedString(data.config.urlInputPrefix, this.urlInputPrefix); | 128 | this.hasCustomUrl, |
117 | this.urlInputSuffix = ifUndefinedString(data.config.urlInputSuffix, this.urlInputSuffix); | 129 | ); |
118 | this.disablewebsecurity = ifUndefinedBoolean(data.config.disablewebsecurity, this.disablewebsecurity); | 130 | this.hasHostedOption = ifUndefinedBoolean( |
119 | this.autoHibernate = ifUndefinedBoolean(data.config.autoHibernate, this.autoHibernate); | 131 | data.config.hasHostedOption, |
132 | this.hasHostedOption, | ||
133 | ); | ||
134 | this.urlInputPrefix = ifUndefinedString( | ||
135 | data.config.urlInputPrefix, | ||
136 | this.urlInputPrefix, | ||
137 | ); | ||
138 | this.urlInputSuffix = ifUndefinedString( | ||
139 | data.config.urlInputSuffix, | ||
140 | this.urlInputSuffix, | ||
141 | ); | ||
142 | this.disablewebsecurity = ifUndefinedBoolean( | ||
143 | data.config.disablewebsecurity, | ||
144 | this.disablewebsecurity, | ||
145 | ); | ||
146 | this.autoHibernate = ifUndefinedBoolean( | ||
147 | data.config.autoHibernate, | ||
148 | this.autoHibernate, | ||
149 | ); | ||
120 | this.message = ifUndefinedString(data.config.message, this.message); | 150 | this.message = ifUndefinedString(data.config.message, this.message); |
121 | this.allowFavoritesDelineationInUnreadCount = ifUndefinedBoolean(data.config.allowFavoritesDelineationInUnreadCount, this.allowFavoritesDelineationInUnreadCount); | 151 | this.allowFavoritesDelineationInUnreadCount = ifUndefinedBoolean( |
152 | data.config.allowFavoritesDelineationInUnreadCount, | ||
153 | this.allowFavoritesDelineationInUnreadCount, | ||
154 | ); | ||
122 | 155 | ||
123 | // computed | 156 | // computed |
124 | this.path = data.path; | 157 | this.path = data.path; |