From 9a569f64da6058d834d3e0c3b22ed3c44d9b2c5f Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Thu, 26 Feb 2015 11:11:23 +0100 Subject: [PATCH] Upgrade to js-tokens@1.0.0 This commit also adds syntax highlighting for `null`, `false` and `true`. --- package.json | 2 +- src/babel/helpers/code-frame.js | 27 +++++++++++++-------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index a4762b0213..ec810e47e6 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "fs-readdir-recursive": "^0.1.0", "globals": "^6.2.0", "is-integer": "^1.0.4", - "js-tokens": "0.4.1", + "js-tokens": "^1.0.0", "leven": "^1.0.1", "line-numbers": "0.2.0", "lodash": "^3.2.0", diff --git a/src/babel/helpers/code-frame.js b/src/babel/helpers/code-frame.js index ef26a80d99..9c8505ae85 100644 --- a/src/babel/helpers/code-frame.js +++ b/src/babel/helpers/code-frame.js @@ -6,18 +6,17 @@ import chalk from "chalk"; import ary from "lodash/function/ary"; var defs = { - string: chalk.red, - punctuation: chalk.white.bold, - operator: chalk.white.bold, - curly: chalk.green, - parens: chalk.blue.bold, - square: chalk.yellow, - name: chalk.white, - keyword: chalk.cyan, - number: chalk.magenta, - regex: chalk.magenta, - comment: chalk.grey, - invalid: chalk.inverse + string: chalk.red, + punctuator: chalk.white.bold, + curly: chalk.green, + parens: chalk.blue.bold, + square: chalk.yellow, + name: chalk.white, + keyword: chalk.cyan, + number: chalk.magenta, + regex: chalk.magenta, + comment: chalk.grey, + invalid: chalk.inverse }; var newline = /\r\n|[\n\r\u2028\u2029]/; @@ -25,11 +24,11 @@ var newline = /\r\n|[\n\r\u2028\u2029]/; var highlight = function (text) { var tokenType = function (match) { var token = jsTokens.matchToToken(match); - if (token.type === "name" && esutils.keyword.isKeywordES6(token.value)) { + if (token.type === "name" && esutils.keyword.isReservedWordES6(token.value)) { return "keyword"; } - if (token.type === "punctuation") { + if (token.type === "punctuator") { switch (token.value) { case "{": case "}":