@putout/printer 1.8.11 → 1.9.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
package/lib/tokenize/debug.js
CHANGED
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
const {TYPES} = require('../types');
|
|
4
4
|
const toSnakeCase = require('just-snake-case');
|
|
5
|
-
const {
|
|
5
|
+
const {
|
|
6
|
+
LOG,
|
|
7
|
+
LOG_ALL,
|
|
8
|
+
DEBUG,
|
|
9
|
+
} = process.env;
|
|
6
10
|
const {codeFrameColumns} = require('@babel/code-frame');
|
|
7
11
|
|
|
8
12
|
module.exports.createDebug = (tokens) => (a) => {
|
|
@@ -16,17 +20,23 @@ module.exports.createDebug = (tokens) => (a) => {
|
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
module.exports.createLog = ({newline = '\n', store = createStore()} = {}) => (chunk) => {
|
|
19
|
-
if (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (chunk === newline) {
|
|
23
|
-
console.log(codeFrameColumns(store(), {}, {
|
|
23
|
+
if (LOG_ALL) {
|
|
24
|
+
console.log(codeFrameColumns(chunk, {}, {
|
|
24
25
|
highlightCode: true,
|
|
25
26
|
}));
|
|
26
27
|
return;
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
if (LOG) {
|
|
31
|
+
if (chunk === newline) {
|
|
32
|
+
console.log(codeFrameColumns(store(), {}, {
|
|
33
|
+
highlightCode: true,
|
|
34
|
+
}));
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
store(chunk);
|
|
39
|
+
}
|
|
30
40
|
};
|
|
31
41
|
|
|
32
42
|
function createStore() {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {isFirst} = require('../is');
|
|
4
|
+
|
|
5
|
+
module.exports.ExportDefaultDeclaration = (path, {print}) => {
|
|
6
|
+
if (shouldAddNewlineBefore(path))
|
|
7
|
+
print.newline();
|
|
8
|
+
|
|
9
|
+
print('export default ');
|
|
10
|
+
print('__declaration');
|
|
11
|
+
print(';');
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function shouldAddNewlineBefore(path) {
|
|
15
|
+
if (isFirst(path))
|
|
16
|
+
return false;
|
|
17
|
+
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
@@ -14,12 +14,14 @@ const exportDeclarations = require('./export-declarations');
|
|
|
14
14
|
const {WhileStatement} = require('./while-statement');
|
|
15
15
|
const {SwitchStatement} = require('./switch-statement');
|
|
16
16
|
const {ForInStatement} = require('./for-in-statement');
|
|
17
|
+
const {ExportDefaultDeclaration} = require('./export-default-declaration');
|
|
17
18
|
|
|
18
19
|
module.exports = {
|
|
19
20
|
...importDeclarations,
|
|
20
21
|
...exportDeclarations,
|
|
21
22
|
BlockStatement,
|
|
22
23
|
ExpressionStatement,
|
|
24
|
+
ExportDefaultDeclaration,
|
|
23
25
|
VariableDeclaration,
|
|
24
26
|
IfStatement,
|
|
25
27
|
ForStatement,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@putout/printer",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.9.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
|
|
6
6
|
"description": "Easiest possible opinionated Babel AST printer made with ❤️ to use in 🐊Putout",
|