fhdp-extenders 4.10.5-SNAPSHOT-1669889569967 → 4.10.401
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Module.ts +84 -84
- package/README.md +97 -97
- package/cached-package.json +1 -1
- package/package.json +3 -3
- package/postpublish.js +15 -15
- package/prepublish.js +15 -15
- package/source/RelocatorRules.ts +216 -216
- package/source/extenders/CookieParser.ts +8 -8
- package/source/extenders/CookiePoliticsHandler.ts +101 -101
- package/source/extenders/DynamicRelocator.ts +71 -71
- package/source/extenders/FHMLExtender.ts +311 -311
- package/source/extenders/PortalProcessHandler.ts +176 -176
- package/tsconfig.json +18 -18
package/Module.ts
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
import {getCookie} from "./source/extenders/CookieParser";
|
|
2
|
-
import {addTranslationForCookiePolitics, rerenderCookieAlert} from "./source/extenders/CookiePoliticsHandler";
|
|
3
|
-
import {addRule, excludeRule} from "./source/extenders/DynamicRelocator";
|
|
4
|
-
import {extendFHML} from "./source/extenders/FHMLExtender"
|
|
5
|
-
import {
|
|
6
|
-
// addFHMLToTooltipRule,
|
|
7
|
-
// excludeSessionCounterRule,
|
|
8
|
-
initCurrentMenuElementHighlightRule,
|
|
9
|
-
initDynamicFooterPositionRule,
|
|
10
|
-
initErrorBelowFieldRule,
|
|
11
|
-
initMobileNavbarRules,
|
|
12
|
-
SET_BORDER_WINDOW_WIDHT
|
|
13
|
-
} from "./source/RelocatorRules";
|
|
14
|
-
|
|
15
|
-
export interface DynamicRelocatorExtensionRule {
|
|
16
|
-
type: 'extension';
|
|
17
|
-
selector: string;
|
|
18
|
-
condition: (mutation: any) => Promise<boolean>;
|
|
19
|
-
ruleMutator: (mutation: any) => Promise<void>;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface DynamicRelocatorExclusionRule {
|
|
23
|
-
type: 'exclusion';
|
|
24
|
-
selector: string;
|
|
25
|
-
condition: (mutation: any) => Promise<boolean>;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface ExtenderConfig {
|
|
29
|
-
i18n: any;
|
|
30
|
-
extendFHML?: boolean;
|
|
31
|
-
mobileMaxWidth?: number;
|
|
32
|
-
enableMobileNavbar?: boolean;
|
|
33
|
-
enableErrorBelowField?: boolean;
|
|
34
|
-
enableDynamicFooterPosition?: boolean;
|
|
35
|
-
enableCurrentMenuElementHighlight?:boolean;
|
|
36
|
-
currentMenuElementHighlighBottomBorderStyle?: string;
|
|
37
|
-
enableFHMLinTooltips?: boolean;
|
|
38
|
-
enableSessionCounterRules?: boolean;
|
|
39
|
-
enableCookieAlert?: boolean;
|
|
40
|
-
additionalRules?: Array<DynamicRelocatorExclusionRule | DynamicRelocatorExtensionRule>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
class FHDPExtender {
|
|
44
|
-
constructor(config: ExtenderConfig) {
|
|
45
|
-
if (config.extendFHML) {
|
|
46
|
-
extendFHML();
|
|
47
|
-
}
|
|
48
|
-
if (config.mobileMaxWidth) {
|
|
49
|
-
SET_BORDER_WINDOW_WIDHT(config.mobileMaxWidth);
|
|
50
|
-
}
|
|
51
|
-
if (config.enableMobileNavbar) {
|
|
52
|
-
initMobileNavbarRules();
|
|
53
|
-
}
|
|
54
|
-
if (config.enableErrorBelowField) {
|
|
55
|
-
initErrorBelowFieldRule();
|
|
56
|
-
}
|
|
57
|
-
if (config.enableDynamicFooterPosition) {
|
|
58
|
-
initDynamicFooterPositionRule()
|
|
59
|
-
}
|
|
60
|
-
if(config.enableCurrentMenuElementHighlight) {
|
|
61
|
-
initCurrentMenuElementHighlightRule(config.currentMenuElementHighlighBottomBorderStyle || '3px solid #ffc107');
|
|
62
|
-
}
|
|
63
|
-
// if (config.enableFHMLinTooltips) {
|
|
64
|
-
// addFHMLToTooltipRule();
|
|
65
|
-
// }
|
|
66
|
-
// if (config.enableSessionCounterRules === undefined || config.enableSessionCounterRules === true) {
|
|
67
|
-
// excludeSessionCounterRule();
|
|
68
|
-
// }
|
|
69
|
-
if (config.enableCookieAlert) {
|
|
70
|
-
rerenderCookieAlert(config.i18n);
|
|
71
|
-
}
|
|
72
|
-
if (config.additionalRules && config.additionalRules.length > 0) {
|
|
73
|
-
for (const rule of config.additionalRules) {
|
|
74
|
-
if (rule.type === 'exclusion') {
|
|
75
|
-
excludeRule(rule.selector, rule.condition)
|
|
76
|
-
} else if (rule.type === 'extension') {
|
|
77
|
-
addRule(rule.selector, rule.condition, rule.ruleMutator);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export {FHDPExtender, getCookie, addTranslationForCookiePolitics}
|
|
1
|
+
import {getCookie} from "./source/extenders/CookieParser";
|
|
2
|
+
import {addTranslationForCookiePolitics, rerenderCookieAlert} from "./source/extenders/CookiePoliticsHandler";
|
|
3
|
+
import {addRule, excludeRule} from "./source/extenders/DynamicRelocator";
|
|
4
|
+
import {extendFHML} from "./source/extenders/FHMLExtender"
|
|
5
|
+
import {
|
|
6
|
+
// addFHMLToTooltipRule,
|
|
7
|
+
// excludeSessionCounterRule,
|
|
8
|
+
initCurrentMenuElementHighlightRule,
|
|
9
|
+
initDynamicFooterPositionRule,
|
|
10
|
+
initErrorBelowFieldRule,
|
|
11
|
+
initMobileNavbarRules,
|
|
12
|
+
SET_BORDER_WINDOW_WIDHT
|
|
13
|
+
} from "./source/RelocatorRules";
|
|
14
|
+
|
|
15
|
+
export interface DynamicRelocatorExtensionRule {
|
|
16
|
+
type: 'extension';
|
|
17
|
+
selector: string;
|
|
18
|
+
condition: (mutation: any) => Promise<boolean>;
|
|
19
|
+
ruleMutator: (mutation: any) => Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface DynamicRelocatorExclusionRule {
|
|
23
|
+
type: 'exclusion';
|
|
24
|
+
selector: string;
|
|
25
|
+
condition: (mutation: any) => Promise<boolean>;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ExtenderConfig {
|
|
29
|
+
i18n: any;
|
|
30
|
+
extendFHML?: boolean;
|
|
31
|
+
mobileMaxWidth?: number;
|
|
32
|
+
enableMobileNavbar?: boolean;
|
|
33
|
+
enableErrorBelowField?: boolean;
|
|
34
|
+
enableDynamicFooterPosition?: boolean;
|
|
35
|
+
enableCurrentMenuElementHighlight?:boolean;
|
|
36
|
+
currentMenuElementHighlighBottomBorderStyle?: string;
|
|
37
|
+
enableFHMLinTooltips?: boolean;
|
|
38
|
+
enableSessionCounterRules?: boolean;
|
|
39
|
+
enableCookieAlert?: boolean;
|
|
40
|
+
additionalRules?: Array<DynamicRelocatorExclusionRule | DynamicRelocatorExtensionRule>;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class FHDPExtender {
|
|
44
|
+
constructor(config: ExtenderConfig) {
|
|
45
|
+
if (config.extendFHML) {
|
|
46
|
+
extendFHML();
|
|
47
|
+
}
|
|
48
|
+
if (config.mobileMaxWidth) {
|
|
49
|
+
SET_BORDER_WINDOW_WIDHT(config.mobileMaxWidth);
|
|
50
|
+
}
|
|
51
|
+
if (config.enableMobileNavbar) {
|
|
52
|
+
initMobileNavbarRules();
|
|
53
|
+
}
|
|
54
|
+
if (config.enableErrorBelowField) {
|
|
55
|
+
initErrorBelowFieldRule();
|
|
56
|
+
}
|
|
57
|
+
if (config.enableDynamicFooterPosition) {
|
|
58
|
+
initDynamicFooterPositionRule()
|
|
59
|
+
}
|
|
60
|
+
if(config.enableCurrentMenuElementHighlight) {
|
|
61
|
+
initCurrentMenuElementHighlightRule(config.currentMenuElementHighlighBottomBorderStyle || '3px solid #ffc107');
|
|
62
|
+
}
|
|
63
|
+
// if (config.enableFHMLinTooltips) {
|
|
64
|
+
// addFHMLToTooltipRule();
|
|
65
|
+
// }
|
|
66
|
+
// if (config.enableSessionCounterRules === undefined || config.enableSessionCounterRules === true) {
|
|
67
|
+
// excludeSessionCounterRule();
|
|
68
|
+
// }
|
|
69
|
+
if (config.enableCookieAlert) {
|
|
70
|
+
rerenderCookieAlert(config.i18n);
|
|
71
|
+
}
|
|
72
|
+
if (config.additionalRules && config.additionalRules.length > 0) {
|
|
73
|
+
for (const rule of config.additionalRules) {
|
|
74
|
+
if (rule.type === 'exclusion') {
|
|
75
|
+
excludeRule(rule.selector, rule.condition)
|
|
76
|
+
} else if (rule.type === 'extension') {
|
|
77
|
+
addRule(rule.selector, rule.condition, rule.ruleMutator);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export {FHDPExtender, getCookie, addTranslationForCookiePolitics}
|
package/README.md
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
# FHDP-Extender
|
|
2
|
-
This library extends abilities of stock fh behaviors.
|
|
3
|
-
|
|
4
|
-
It works on Mutator Observer and inject code between luna rendering, and displaying it on client side.
|
|
5
|
-
Also includes fhml extender.
|
|
6
|
-
|
|
7
|
-
## How to use
|
|
8
|
-
|
|
9
|
-
### cookie parser
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
import {getCookie} from 'fhdp-extenders';
|
|
13
|
-
|
|
14
|
-
...
|
|
15
|
-
|
|
16
|
-
const cookie = getCookie();
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
it returns cookie dictionary parsed to json.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
### init extenders
|
|
23
|
-
|
|
24
|
-
```
|
|
25
|
-
import {FHDPExtender} from 'fhdp-extenders';
|
|
26
|
-
|
|
27
|
-
...
|
|
28
|
-
|
|
29
|
-
new FHDPExtender({
|
|
30
|
-
i18n: i18nInstance, /* needs to provide i18n instance to handle translations*/
|
|
31
|
-
extendFHML: true, /* extends fhml */
|
|
32
|
-
enableMobileNavbar: true, /* enable changing from desktop to mobile navbar */
|
|
33
|
-
enableHintOnHover: true, /* enable hints on hover */
|
|
34
|
-
enableRequiredAtLabel: true, /* enable moving required star from field to label */
|
|
35
|
-
enableErrorBelowField: true, /* enable moving error from field to label */
|
|
36
|
-
enableDynamicFooterPosition: true, /* enable dynamic footer sliding */
|
|
37
|
-
enableCurrentMenuElementHighlight: true, /* enable highlight for currently selected element */
|
|
38
|
-
enableFHMLinTooltips: true, /* enable fhml in tooltips */
|
|
39
|
-
enableSessionCounterRules: true, /* enable session counter rules */
|
|
40
|
-
enableCookieAlert: true, /* enable cookie alert at bottom */
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
### extend translations for cookie alert
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
import {addTranslationForCookiePolitics} from 'fhdp-extenders';
|
|
50
|
-
|
|
51
|
-
addTranslationForCookiePolitics('pl' {
|
|
52
|
-
warning: 'Uwaga!',
|
|
53
|
-
message: 'Używając tej strony akceptujesz politykę prywatności i przetwarzanie plików cookie',
|
|
54
|
-
close: 'Akceptuję'
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
### extend rules
|
|
60
|
-
|
|
61
|
-
In FHDPExtender config add node `additionalRules`.
|
|
62
|
-
This is list of objects:
|
|
63
|
-
```
|
|
64
|
-
{
|
|
65
|
-
// 'exclusion' type excludes all mutations described by condition param,
|
|
66
|
-
// 'extension' type extends rules. For this param ruleMutator is obligatory
|
|
67
|
-
type: 'exclusion' | 'extension'
|
|
68
|
-
// 'selector' its marker for recognising whitch element is selected (only used in debug),
|
|
69
|
-
selector: string
|
|
70
|
-
// async function for recognisiong if element fits into mutation rule
|
|
71
|
-
condition: (mutation: Mutation) => Promise<boolean>
|
|
72
|
-
// rule mutator is actual function that modifies elements in DOM. It runs only if type = extension and condition returns true.
|
|
73
|
-
ruleMutator: (mutation: Mutation) => Promise<void>
|
|
74
|
-
}
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
Example adding div to dom only if not exists:
|
|
78
|
-
|
|
79
|
-
```
|
|
80
|
-
new FHDPExtender({
|
|
81
|
-
i18n: i18nInstance,
|
|
82
|
-
additionalRules: [
|
|
83
|
-
{
|
|
84
|
-
type: 'extension',
|
|
85
|
-
selector: '#myComponent',
|
|
86
|
-
condition: async (mutation) => !!document.querySelector('#myComponent'),
|
|
87
|
-
ruleMutator: async (mutation) => {
|
|
88
|
-
const myElement = document.createElement(div);
|
|
89
|
-
myElement.id = '#myComponent';
|
|
90
|
-
myElement.innerText = 'Thats my element!';
|
|
91
|
-
document.body.appendChild(myElement);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
...
|
|
95
|
-
]
|
|
96
|
-
});
|
|
97
|
-
```
|
|
1
|
+
# FHDP-Extender
|
|
2
|
+
This library extends abilities of stock fh behaviors.
|
|
3
|
+
|
|
4
|
+
It works on Mutator Observer and inject code between luna rendering, and displaying it on client side.
|
|
5
|
+
Also includes fhml extender.
|
|
6
|
+
|
|
7
|
+
## How to use
|
|
8
|
+
|
|
9
|
+
### cookie parser
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
import {getCookie} from 'fhdp-extenders';
|
|
13
|
+
|
|
14
|
+
...
|
|
15
|
+
|
|
16
|
+
const cookie = getCookie();
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
it returns cookie dictionary parsed to json.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### init extenders
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
import {FHDPExtender} from 'fhdp-extenders';
|
|
26
|
+
|
|
27
|
+
...
|
|
28
|
+
|
|
29
|
+
new FHDPExtender({
|
|
30
|
+
i18n: i18nInstance, /* needs to provide i18n instance to handle translations*/
|
|
31
|
+
extendFHML: true, /* extends fhml */
|
|
32
|
+
enableMobileNavbar: true, /* enable changing from desktop to mobile navbar */
|
|
33
|
+
enableHintOnHover: true, /* enable hints on hover */
|
|
34
|
+
enableRequiredAtLabel: true, /* enable moving required star from field to label */
|
|
35
|
+
enableErrorBelowField: true, /* enable moving error from field to label */
|
|
36
|
+
enableDynamicFooterPosition: true, /* enable dynamic footer sliding */
|
|
37
|
+
enableCurrentMenuElementHighlight: true, /* enable highlight for currently selected element */
|
|
38
|
+
enableFHMLinTooltips: true, /* enable fhml in tooltips */
|
|
39
|
+
enableSessionCounterRules: true, /* enable session counter rules */
|
|
40
|
+
enableCookieAlert: true, /* enable cookie alert at bottom */
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### extend translations for cookie alert
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
import {addTranslationForCookiePolitics} from 'fhdp-extenders';
|
|
50
|
+
|
|
51
|
+
addTranslationForCookiePolitics('pl' {
|
|
52
|
+
warning: 'Uwaga!',
|
|
53
|
+
message: 'Używając tej strony akceptujesz politykę prywatności i przetwarzanie plików cookie',
|
|
54
|
+
close: 'Akceptuję'
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### extend rules
|
|
60
|
+
|
|
61
|
+
In FHDPExtender config add node `additionalRules`.
|
|
62
|
+
This is list of objects:
|
|
63
|
+
```
|
|
64
|
+
{
|
|
65
|
+
// 'exclusion' type excludes all mutations described by condition param,
|
|
66
|
+
// 'extension' type extends rules. For this param ruleMutator is obligatory
|
|
67
|
+
type: 'exclusion' | 'extension'
|
|
68
|
+
// 'selector' its marker for recognising whitch element is selected (only used in debug),
|
|
69
|
+
selector: string
|
|
70
|
+
// async function for recognisiong if element fits into mutation rule
|
|
71
|
+
condition: (mutation: Mutation) => Promise<boolean>
|
|
72
|
+
// rule mutator is actual function that modifies elements in DOM. It runs only if type = extension and condition returns true.
|
|
73
|
+
ruleMutator: (mutation: Mutation) => Promise<void>
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Example adding div to dom only if not exists:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
new FHDPExtender({
|
|
81
|
+
i18n: i18nInstance,
|
|
82
|
+
additionalRules: [
|
|
83
|
+
{
|
|
84
|
+
type: 'extension',
|
|
85
|
+
selector: '#myComponent',
|
|
86
|
+
condition: async (mutation) => !!document.querySelector('#myComponent'),
|
|
87
|
+
ruleMutator: async (mutation) => {
|
|
88
|
+
const myElement = document.createElement(div);
|
|
89
|
+
myElement.id = '#myComponent';
|
|
90
|
+
myElement.innerText = 'Thats my element!';
|
|
91
|
+
document.body.appendChild(myElement);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
...
|
|
95
|
+
]
|
|
96
|
+
});
|
|
97
|
+
```
|
package/cached-package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"fhdp-extenders","version":"4.10.
|
|
1
|
+
{"name":"fhdp-extenders","version":"4.10.401","author":{"name":"Jakub Kosecki","email":"j.kosecki@doittechnology.pl"},"main":"dist/Module.js","types":"dist/Module.d.ts","scripts":{"prepublish":"node prepublish","postpublish":"node postpublish","build":"tsc","prepare":"yarn build","test":"echo \"Error: no test specified\" && exit 1"},"devDependencies":{"@types/bootstrap":"4.3.1","@types/jquery":"3.3.31","@types/node":"14.14.36","typescript":"3.5.3"},"dependencies":{"fh-basic-controls":"4.10.401","fh-forms-handler":"4.10.401","lodash":"4.17.21","moment":"^2.24.0","moment-timezone":"0.5.34"}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fhdp-extenders",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.401",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Jakub Kosecki",
|
|
6
6
|
"email": "j.kosecki@doittechnology.pl"
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"typescript": "3.5.3"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"fh-basic-controls": "4.10.
|
|
25
|
-
"fh-forms-handler": "4.10.
|
|
24
|
+
"fh-basic-controls": "4.10.401",
|
|
25
|
+
"fh-forms-handler": "4.10.401",
|
|
26
26
|
"lodash": "4.17.21",
|
|
27
27
|
"moment": "^2.24.0",
|
|
28
28
|
"moment-timezone": "0.5.34"
|
package/postpublish.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
|
|
4
|
-
const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
|
|
5
|
-
const pkgData = JSON.stringify(require(CACHED_PKG_PATH), null, 2) + '\n';
|
|
6
|
-
|
|
7
|
-
fs.writeFile(ORIG_PKG_PATH, pkgData, function (err) {
|
|
8
|
-
if (err) throw err;
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
pkgData.main = 'Module.ts';
|
|
12
|
-
|
|
13
|
-
fs.unlink(CACHED_PKG_PATH, function (err) {
|
|
14
|
-
if (err) throw err;
|
|
15
|
-
});
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
|
|
4
|
+
const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
|
|
5
|
+
const pkgData = JSON.stringify(require(CACHED_PKG_PATH), null, 2) + '\n';
|
|
6
|
+
|
|
7
|
+
fs.writeFile(ORIG_PKG_PATH, pkgData, function (err) {
|
|
8
|
+
if (err) throw err;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
pkgData.main = 'Module.ts';
|
|
12
|
+
|
|
13
|
+
fs.unlink(CACHED_PKG_PATH, function (err) {
|
|
14
|
+
if (err) throw err;
|
|
15
|
+
});
|
package/prepublish.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
|
|
4
|
-
const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
|
|
5
|
-
const pkgData = require(ORIG_PKG_PATH);
|
|
6
|
-
|
|
7
|
-
fs.writeFile(CACHED_PKG_PATH, JSON.stringify(pkgData), function (err) {
|
|
8
|
-
if (err) throw err;
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
pkgData.main = 'dist/Module.js';
|
|
12
|
-
|
|
13
|
-
fs.writeFile(ORIG_PKG_PATH, JSON.stringify(pkgData, null, 2), function (err) {
|
|
14
|
-
if (err) throw err;
|
|
15
|
-
});
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const ORIG_PKG_PATH = path.resolve(__dirname, 'package.json');
|
|
4
|
+
const CACHED_PKG_PATH = path.resolve(__dirname, 'cached-package.json');
|
|
5
|
+
const pkgData = require(ORIG_PKG_PATH);
|
|
6
|
+
|
|
7
|
+
fs.writeFile(CACHED_PKG_PATH, JSON.stringify(pkgData), function (err) {
|
|
8
|
+
if (err) throw err;
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
pkgData.main = 'dist/Module.js';
|
|
12
|
+
|
|
13
|
+
fs.writeFile(ORIG_PKG_PATH, JSON.stringify(pkgData, null, 2), function (err) {
|
|
14
|
+
if (err) throw err;
|
|
15
|
+
});
|