react-responsive-tools 2.0.6 → 2.0.8

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-responsive-tools",
3
- "version": "2.0.6",
3
+ "version": "2.0.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "module": "index.js",
@@ -1,15 +1,15 @@
1
- // mergeBreakpointConfigs.js
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.js';
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, '../breakpoints.config.js');
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
- const userConfig = await import(userConfigPath);
27
- horizontalBreakpoints = mergeConfigs(defaultHorizontalBreakpoints, userConfig.HORIZONTAL_BREAKPOINTS || {});
28
- verticalBreakpoints = mergeConfigs(defaultVerticalBreakpoints, userConfig.VERTICAL_BREAKPOINTS || {});
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
- // Создаем новый файл с именем breakpoints.config.js
41
- fs.writeFileSync(
42
- path.resolve(__dirname, '../breakpoints.config.js'),
43
- mergedConfigContent
44
- );
45
-
46
- console.log('Config file have been generated successfully.');
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();
@@ -2,7 +2,7 @@
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url'; // Импортируем необходимую функцию из 'url'
5
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.js';
5
+ import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.mjs';
6
6
 
7
7
  // Определение __filename и __dirname
8
8
  const __filename = fileURLToPath(import.meta.url);
@@ -2,7 +2,7 @@
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url';
5
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.js';
5
+ import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.mjs';
6
6
 
7
7
  // Определение __filename и __dirname
8
8
  const __filename = fileURLToPath(import.meta.url);
@@ -2,7 +2,7 @@
2
2
  import fs from 'fs';
3
3
  import path from 'path';
4
4
  import { fileURLToPath } from 'url';
5
- import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.js';
5
+ import { HORIZONTAL_BREAKPOINTS, VERTICAL_BREAKPOINTS } from '../breakpoints.config.mjs';
6
6
 
7
7
  // Определение __filename и __dirname
8
8
  const __filename = fileURLToPath(import.meta.url);
File without changes