redput 4.3.0 → 4.4.0

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/ChangeLog CHANGED
@@ -1,3 +1,9 @@
1
+ 2026.05.10, v4.4.0
2
+
3
+ feature:
4
+ - 102a7c3 redput: write: nested: search for the same name of js as plugin name first
5
+ - 0e81a86 redput: supertape v13.0.0
6
+
1
7
  2026.05.05, v4.3.0
2
8
 
3
9
  feature:
@@ -1,4 +1,5 @@
1
1
  import {
2
+ access as _access,
2
3
  mkdir,
3
4
  readFile,
4
5
  writeFile,
@@ -10,6 +11,7 @@ import {
10
11
  } from 'node:path';
11
12
  import process from 'node:process';
12
13
  import {rendy} from 'rendy';
14
+ import {tryToCatch} from 'try-to-catch';
13
15
  import {addRule} from './add-rule/add-rule.js';
14
16
  import {insertTest} from './insert-test/insert-test.js';
15
17
  import {prepareRule} from './prepare-rule/prepare-rule.js';
@@ -47,17 +49,37 @@ export const writeNestedTests = async (name, report) => {
47
49
  }));
48
50
  };
49
51
 
50
- export const updateNestedIndex = async (name, options) => {
51
- const source = await readFile('./index.js', 'utf8');
52
+ export const updateNestedIndex = async (name, options, overrides = {}) => {
53
+ const {
54
+ read = readFile,
55
+ write = writeFile,
56
+ access = _access,
57
+ plugin = getPluginName(process.cwd()),
58
+ } = overrides;
59
+
60
+ const [error] = await tryToCatch(access, `./${plugin}.js`);
61
+
62
+ if (error) {
63
+ const source = await read('./index.js', 'utf8');
64
+ const code = addRule(name, source, options);
65
+
66
+ await write(`./index.js`, code);
67
+ return;
68
+ }
69
+
70
+ const source = await read(`./${plugin}.js`, 'utf8');
52
71
  const code = addRule(name, source, options);
53
72
 
54
- await writeFile(`./index.js`, code);
73
+ await write(`./${plugin}.js`, code);
74
+ };
75
+
76
+ const getPluginName = (dir) => {
77
+ const nestedPluginName = basename(dirname(join(dir)));
78
+ return nestedPluginName.replace('plugin-', '');
55
79
  };
56
80
 
57
81
  export const updateOverallNestedTest = async (name) => {
58
- const nestedPluginName = basename(dirname(join(process.cwd())));
59
- const plugin = nestedPluginName.replace('plugin-', '');
60
-
82
+ const plugin = getPluginName(process.cwd());
61
83
  const source = await readFile(`../test/${plugin}.js`, 'utf8');
62
84
  const code = insertTest(name, plugin, source);
63
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redput",
3
- "version": "4.3.0",
3
+ "version": "4.4.0",
4
4
  "description": "CLI tool to convert source from 🐊Putout Editor to files",
5
5
  "main": "lib/redput.js",
6
6
  "bin": {
@@ -77,7 +77,7 @@
77
77
  "nodemon": "^3.0.1",
78
78
  "redlint": "^6.0.0",
79
79
  "superc8": "^12.2.4",
80
- "supertape": "^12.0.0"
80
+ "supertape": "^13.0.0"
81
81
  },
82
82
  "publishConfig": {
83
83
  "access": "public"