Skip to content

Commit 6ac3a36

Browse files
authored
Refactor The Code (#8)
1 parent b6ca4c8 commit 6ac3a36

37 files changed

+657
-755
lines changed

lib/const/FeatureFlag/FeatureFlag.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class FeatureFlag {
2+
3+
/** Whether to cache the downloaded comics locally for offline reuse. */
4+
static XKCD_WIDGET_ENABLE_LOCAL_CACHE = true
5+
}
6+
7+
module.exports = {
8+
FeatureFlag,
9+
}

lib/const/FeatureFlag/index.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1-
module.exports = {
1+
// If running outside the Scriptable environment...
2+
if (typeof config === 'undefined') {
3+
// ... overwrite the `importModule()` global function.
4+
global.importModule = modulePath => require(modulePath)
5+
}
26

3-
LOG_MODULE_IMPORTS: true,
7+
const { FeatureFlag } = importModule('./FeatureFlag')
48

5-
/** Whether to cache the downloaded comics locally for offline reuse. */
6-
XKCD_WIDGET_ENABLE_LOCAL_CACHE: true,
7-
};
9+
module.exports = {
10+
FeatureFlag,
11+
}

lib/const/LocalPath/LocalPath.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class LocalPath {
2+
3+
static LOCAL_CACHE_DIRNAME = 'cache'
4+
5+
static XKCD_CACHE_FILENAME = 'random-xkcd-widget-cache.json'
6+
static XKCD_CACHE_IMAGE_FILENAME = 'random-xkcd-widget-cache-image'
7+
}
8+
9+
module.exports = {
10+
LocalPath,
11+
}

lib/const/LocalPath/index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
module.exports = {
1+
// If running outside the Scriptable environment...
2+
if (typeof config === 'undefined') {
3+
// ... overwrite the `importModule()` global function.
4+
global.importModule = modulePath => require(modulePath)
5+
}
26

3-
LOCAL_CACHE_DIRNAME: 'cache',
7+
const { LocalPath } = importModule('./LocalPath')
48

5-
XKCD_CACHE_FILENAME: 'random-xkcd-widget-cache.json',
6-
};
9+
module.exports = {
10+
LocalPath,
11+
}

lib/service/XkcdComicService/XkcdComicService.test.js

-123
This file was deleted.

lib/service/XkcdComicService/index.js

-88
This file was deleted.

0 commit comments

Comments
 (0)