putout 35.25.0 → 35.25.1

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,8 @@
1
+ 2024.05.21, v35.25.1
2
+
3
+ fix:
4
+ - aa613221b putout: show error when syntax errors in config file
5
+
1
6
  2024.05.20, v35.25.0
2
7
 
3
8
  feature:
package/bin/tracer.mjs CHANGED
@@ -1,22 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import process from 'node:process';
4
3
  import {Worker} from 'node:worker_threads';
5
- import {subscribe} from '@putout/engine-reporter/subscribe';
6
- import {parseArgs} from '../lib/cli/parse-args.js';
7
-
8
- const {
4
+ import process, {
9
5
  cwd,
10
- exit,
11
6
  stdout,
12
- } = process;
7
+ exit as halt,
8
+ } from 'node:process';
9
+
10
+ import {subscribe} from '@putout/engine-reporter/subscribe';
11
+ import {parseArgs} from '../lib/cli/parse-args.js';
12
+ import {createExit} from '../lib/cli/exit.mjs';
13
13
 
14
14
  const args = parseArgs(process.argv.slice(2));
15
15
  const write = stdout.write.bind(stdout);
16
16
 
17
17
  if (!args.worker) {
18
18
  await import('./putout.mjs');
19
- exit();
19
+ halt();
20
20
  }
21
21
 
22
22
  const slave = new URL('./putout.mjs', import.meta.url);
@@ -29,9 +29,12 @@ const worker = new Worker(slave, {
29
29
  subscribe({
30
30
  args,
31
31
  worker,
32
- exit,
33
32
  cwd,
34
33
  write,
34
+ exit: createExit({
35
+ halt,
36
+ logError: console.error,
37
+ }),
35
38
  });
36
39
 
37
40
  function dropInteractive(argv) {
@@ -0,0 +1,20 @@
1
+ import chalk from 'chalk';
2
+
3
+ const {red} = chalk;
4
+
5
+ export const createExit = ({halt, raw, logError}) => (code, e) => {
6
+ if (!code)
7
+ return halt(0);
8
+
9
+ if (!e)
10
+ return halt(code);
11
+
12
+ const message = raw ? e : red(`🐊 ${e.message || e}`);
13
+
14
+ logError(message);
15
+ halt(code);
16
+
17
+ return {
18
+ exited: true,
19
+ };
20
+ };
package/lib/cli/index.js CHANGED
@@ -99,10 +99,9 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile,
99
99
  plugins,
100
100
  } = args;
101
101
 
102
- const {red} = await simpleImport('chalk');
102
+ const {createExit} = await simpleImport('./exit.mjs');
103
103
 
104
- const exit = getExit({
105
- red,
104
+ const exit = createExit({
106
105
  raw,
107
106
  halt,
108
107
  logError,
@@ -321,23 +320,6 @@ module.exports = async ({argv, halt, log, write, logError, readFile, writeFile,
321
320
  exit(exitCode);
322
321
  };
323
322
 
324
- const getExit = ({red, halt, raw, logError}) => (code, e) => {
325
- if (!code)
326
- return halt(0);
327
-
328
- if (!e)
329
- return halt(code);
330
-
331
- const message = raw ? e : red(`🐊 ${e.message || e}`);
332
-
333
- logError(message);
334
- halt(code);
335
-
336
- return {
337
- exited: true,
338
- };
339
- };
340
-
341
323
  module.exports._addOnce = addOnce;
342
324
  function addOnce(emitter, name, fn) {
343
325
  if (!emitter.listenerCount(name))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "putout",
3
- "version": "35.25.0",
3
+ "version": "35.25.1",
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",