putout 35.35.7 → 35.36.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 +17 -0
- package/README.md +16 -2
- package/bin/debugger-exit.mjs +17 -0
- package/bin/putout.mjs +8 -0
- package/lib/putout.js +5 -4
- package/lib/putout.mjs +1 -10
- package/package.json +2 -2
package/ChangeLog
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
2024.06.25, v35.36.0
|
|
2
|
+
|
|
3
|
+
feature:
|
|
4
|
+
- 3d798f3f7 putout: add ability to import as specifier "putout"
|
|
5
|
+
- 7e813cb26 @putout/plugin-putout: check-replace-code: once: add
|
|
6
|
+
|
|
7
|
+
2024.06.25, v35.35.8
|
|
8
|
+
|
|
9
|
+
feature:
|
|
10
|
+
- c999629ba putout: @putout/plugin-remove-useless-return v7.0.0
|
|
11
|
+
- 08198fb04 @putotu/plugin-remove-useless-return: drop support of 🐊 < 35'
|
|
12
|
+
- eaaef62ed @putout/plugin-remove-useless-return: not argument
|
|
13
|
+
- 74819bb59 putout: kill when hang after --inspect
|
|
14
|
+
- 34b1b4c73 @putout/plugin-putout: check-replace-code: split more
|
|
15
|
+
- 4e4f39572 @putout/plugin-putout: check-replace-code: split
|
|
16
|
+
- d675e3d21 @putout/plugin-putout: check-replace-code: esm
|
|
17
|
+
|
|
1
18
|
2024.06.24, v35.35.7
|
|
2
19
|
|
|
3
20
|
fix:
|
package/README.md
CHANGED
|
@@ -283,10 +283,24 @@ For example if you need to `remove-something` create 🐊[**Putout**](https://gi
|
|
|
283
283
|
|
|
284
284
|
## API
|
|
285
285
|
|
|
286
|
-
|
|
286
|
+
All examples works both in **ESM** and **CommonJS**.
|
|
287
|
+
|
|
288
|
+
**CommonJS**:
|
|
287
289
|
|
|
288
290
|
```js
|
|
289
291
|
const putout = require('putout');
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**ESM**:
|
|
295
|
+
|
|
296
|
+
```js
|
|
297
|
+
import {putout} from 'putout';
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### putout(source, options)
|
|
301
|
+
|
|
302
|
+
```js
|
|
303
|
+
import {putout} from 'putout';
|
|
290
304
|
|
|
291
305
|
const source = `
|
|
292
306
|
const t = 'hello';
|
|
@@ -308,7 +322,7 @@ console.log(t);
|
|
|
308
322
|
### putoutAsync(source, options)
|
|
309
323
|
|
|
310
324
|
```js
|
|
311
|
-
|
|
325
|
+
import {putoutAsync} from 'putout';
|
|
312
326
|
|
|
313
327
|
const source = `
|
|
314
328
|
const t = 'hello';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
export const onDebuggerExit = ({log, process, inspector}) => {
|
|
4
|
+
const {pid} = process;
|
|
5
|
+
|
|
6
|
+
process.once('exit', (code) => {
|
|
7
|
+
if (code !== 1)
|
|
8
|
+
return;
|
|
9
|
+
|
|
10
|
+
if (!inspector.url())
|
|
11
|
+
return;
|
|
12
|
+
|
|
13
|
+
inspector.close();
|
|
14
|
+
log(chalk.bgBlueBright(`node --inspect: 'kill ${pid}'`));
|
|
15
|
+
process.kill(pid);
|
|
16
|
+
});
|
|
17
|
+
};
|
package/bin/putout.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import process from 'node:process';
|
|
4
|
+
import inspector from 'node:inspector';
|
|
4
5
|
import {readFile, writeFile} from 'node:fs/promises';
|
|
5
6
|
import {subscribe} from '@putout/engine-reporter/subscribe';
|
|
6
7
|
import {createTrace} from './trace.mjs';
|
|
@@ -10,11 +11,18 @@ import {createCommunication} from './communication.mjs';
|
|
|
10
11
|
import cli from '../lib/cli/index.js';
|
|
11
12
|
import {parseArgs} from '../lib/cli/parse-args.js';
|
|
12
13
|
import {createExit} from '../lib/cli/exit.mjs';
|
|
14
|
+
import {onDebuggerExit} from './debugger-exit.mjs';
|
|
13
15
|
|
|
14
16
|
const halt = process.exit;
|
|
15
17
|
const logError = console.error;
|
|
16
18
|
const {log} = console;
|
|
17
19
|
|
|
20
|
+
onDebuggerExit({
|
|
21
|
+
log,
|
|
22
|
+
process,
|
|
23
|
+
inspector,
|
|
24
|
+
});
|
|
25
|
+
|
|
18
26
|
const {
|
|
19
27
|
worker,
|
|
20
28
|
workerData,
|
package/lib/putout.js
CHANGED
|
@@ -19,7 +19,10 @@ const {
|
|
|
19
19
|
|
|
20
20
|
const isString = (a) => typeof a === 'string';
|
|
21
21
|
|
|
22
|
-
module.exports =
|
|
22
|
+
module.exports = putout;
|
|
23
|
+
module.exports.putout = putout;
|
|
24
|
+
|
|
25
|
+
function putout(source, opts) {
|
|
23
26
|
check(source);
|
|
24
27
|
opts = defaultOptions(opts);
|
|
25
28
|
|
|
@@ -63,9 +66,7 @@ module.exports = (source, opts) => {
|
|
|
63
66
|
code,
|
|
64
67
|
places,
|
|
65
68
|
};
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
module.exports.putoutAsync = async (source, opts) => {
|
|
69
|
+
}module.exports.putoutAsync = async (source, opts) => {
|
|
69
70
|
check(source);
|
|
70
71
|
opts = defaultOptions(opts);
|
|
71
72
|
|
package/lib/putout.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "putout",
|
|
3
|
-
"version": "35.
|
|
3
|
+
"version": "35.36.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "🐊 Pluggable and configurable code transformer with built-in ESLint, Babel and support of js, jsx, typescript, flow, markdown, yaml and json",
|
|
@@ -166,7 +166,7 @@
|
|
|
166
166
|
"@putout/plugin-remove-useless-map": "^1.0.0",
|
|
167
167
|
"@putout/plugin-remove-useless-operand": "^2.0.0",
|
|
168
168
|
"@putout/plugin-remove-useless-replace": "^1.0.1",
|
|
169
|
-
"@putout/plugin-remove-useless-return": "^
|
|
169
|
+
"@putout/plugin-remove-useless-return": "^7.0.0",
|
|
170
170
|
"@putout/plugin-remove-useless-spread": "^11.0.0",
|
|
171
171
|
"@putout/plugin-remove-useless-template-expressions": "^2.0.0",
|
|
172
172
|
"@putout/plugin-remove-useless-variables": "^11.0.0",
|