react-responsive-tools 2.0.5 → 2.0.7
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/package.json +1 -1
- package/reinit.sh +4 -4
- package/src/scripts/createConfig.mjs +21 -13
package/package.json
CHANGED
package/reinit.sh
CHANGED
@@ -6,7 +6,7 @@ PACKAGE_DIR=$(cd "$SCRIPT_DIR" && pwd)
|
|
6
6
|
|
7
7
|
# Запуск createConfig.mjs из пакета
|
8
8
|
echo "Running createConfig.mjs from package..."
|
9
|
-
node "$PACKAGE_DIR
|
9
|
+
node "$PACKAGE_DIR/src/scripts/createConfig.mjs"
|
10
10
|
|
11
11
|
if [ $? -ne 0 ]; then
|
12
12
|
echo "Error occurred while running createConfig.mjs"
|
@@ -15,7 +15,7 @@ fi
|
|
15
15
|
|
16
16
|
# Запуск generateCustomBreakpointsSCSS.mjs из пакета
|
17
17
|
echo "Running generateCustomBreakpointsSCSS.mjs from package..."
|
18
|
-
node "$PACKAGE_DIR
|
18
|
+
node "$PACKAGE_DIR/src/scripts/generateCustomBreakpointsSCSS.mjs"
|
19
19
|
|
20
20
|
if [ $? -ne 0 ]; then
|
21
21
|
echo "Error occurred while running generateCustomBreakpointsSCSS.mjs"
|
@@ -24,7 +24,7 @@ fi
|
|
24
24
|
|
25
25
|
# Запуск generateSCSS.mjs из пакета
|
26
26
|
echo "Running generateSCSS.mjs from package..."
|
27
|
-
node "$PACKAGE_DIR
|
27
|
+
node "$PACKAGE_DIR/src/scripts/generateSCSS.mjs"
|
28
28
|
|
29
29
|
if [ $? -ne 0 ]; then
|
30
30
|
echo "Error occurred while running generateSCSS.mjs"
|
@@ -33,7 +33,7 @@ fi
|
|
33
33
|
|
34
34
|
# Запуск generateTBreakpoint.mjs из пакета
|
35
35
|
echo "Running generateTBreakpoint.mjs from package..."
|
36
|
-
node "$PACKAGE_DIR
|
36
|
+
node "$PACKAGE_DIR/src/scripts/generateTBreakpoint.mjs"
|
37
37
|
|
38
38
|
if [ $? -ne 0 ]; then
|
39
39
|
echo "Error occurred while running generateTBreakpoint.mjs"
|
@@ -1,15 +1,15 @@
|
|
1
|
-
// mergeBreakpointConfigs.
|
1
|
+
// mergeBreakpointConfigs.mjs
|
2
2
|
import fs from 'fs';
|
3
3
|
import path from 'path';
|
4
4
|
import { fileURLToPath } from 'url';
|
5
|
-
import { HORIZONTAL_BREAKPOINTS as defaultHorizontalBreakpoints, VERTICAL_BREAKPOINTS as defaultVerticalBreakpoints } from '../default.config.
|
5
|
+
import { HORIZONTAL_BREAKPOINTS as defaultHorizontalBreakpoints, VERTICAL_BREAKPOINTS as defaultVerticalBreakpoints } from '../default.config.mjs';
|
6
6
|
|
7
7
|
// Определение __filename и __dirname
|
8
8
|
const __filename = fileURLToPath(import.meta.url);
|
9
9
|
const __dirname = path.dirname(__filename);
|
10
10
|
|
11
11
|
// Путь к пользовательскому конфигурационному файлу
|
12
|
-
const userConfigPath = path.resolve(__dirname, '
|
12
|
+
const userConfigPath = path.resolve(__dirname, '../../breakpoints.config.js');
|
13
13
|
|
14
14
|
// Функция объединения значений по умолчанию с пользовательскими значениями
|
15
15
|
const mergeConfigs = (defaultConfig, userConfig) => ({
|
@@ -23,9 +23,16 @@ const mergeBreakpointConfigs = async () => {
|
|
23
23
|
|
24
24
|
// Проверяем, существует ли пользовательский конфигурационный файл
|
25
25
|
if (fs.existsSync(userConfigPath)) {
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
try {
|
27
|
+
const userConfig = await import(userConfigPath);
|
28
|
+
horizontalBreakpoints = mergeConfigs(defaultHorizontalBreakpoints, userConfig.HORIZONTAL_BREAKPOINTS || {});
|
29
|
+
verticalBreakpoints = mergeConfigs(defaultVerticalBreakpoints, userConfig.VERTICAL_BREAKPOINTS || {});
|
30
|
+
console.log('User config loaded and merged successfully.');
|
31
|
+
} catch (error) {
|
32
|
+
console.error('Error loading user config:', error);
|
33
|
+
}
|
34
|
+
} else {
|
35
|
+
console.log('User config file not found, using default breakpoints.');
|
29
36
|
}
|
30
37
|
|
31
38
|
const mergedConfigContent = `
|
@@ -37,13 +44,14 @@ const VERTICAL_BREAKPOINTS = ${JSON.stringify(verticalBreakpoints, null, 2)};
|
|
37
44
|
export { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS };
|
38
45
|
`;
|
39
46
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
)
|
45
|
-
|
46
|
-
|
47
|
+
try {
|
48
|
+
// Создаем новый файл с именем breakpoints.config.js
|
49
|
+
fs.writeFileSync(userConfigPath, mergedConfigContent);
|
50
|
+
console.log('Config file have been generated successfully.');
|
51
|
+
} catch (error) {
|
52
|
+
console.error('Error writing merged config file:', error);
|
53
|
+
}
|
47
54
|
};
|
48
55
|
|
56
|
+
// Запуск функции
|
49
57
|
mergeBreakpointConfigs();
|