You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
568 B
JavaScript

'use strict';
const chalk = require("chalk");
const ansiStyles = require("ansi-styles");
module.exports = function colorizedNodeType(astNode) {
let nodeType = astNode.type;
if (nodeType === "FunctionDeclaration" || nodeType === "ArrowFunctionExpression") {
return chalk.cyan(nodeType);
} else if (nodeType === "CallExpression") {
return chalk.green(nodeType);
} else if (nodeType === "ReturnStatement") {
return chalk.red(nodeType);
} else {
return ansiStyles.color.ansi256.rgb(100, 100, 100) + nodeType;
}
}