From ed85631079a09e40ceff32e427d74cc326e09af6 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Fri, 9 Aug 2019 09:20:40 +0930 Subject: [PATCH 1/2] fix: fs.write instead of stdout --- package.json | 2 +- scripts/build_highlight_alias.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 1c6b92a4..99ad48e2 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "eslint": "eslint .", "test": "mocha test/index.js", "test-cov": "nyc npm run test", - "build:highlight": "node scripts/build_highlight_alias.js > highlight_alias.json", + "build:highlight": "node scripts/build_highlight_alias.js", "prepare": "npm run build:highlight" }, "directories": { diff --git a/scripts/build_highlight_alias.js b/scripts/build_highlight_alias.js index 6f1b6184..36be9973 100644 --- a/scripts/build_highlight_alias.js +++ b/scripts/build_highlight_alias.js @@ -2,6 +2,7 @@ var hljs = require('highlight.js'); var languages = hljs.listLanguages(); +const fs = require('fs'); var result = { languages: languages, @@ -21,4 +22,9 @@ languages.forEach(function(lang) { } }); -console.log(JSON.stringify(result)); +const stream = fs.createWriteStream('highlight_alias.json'); +stream.write(JSON.stringify(result)); +stream.on('end', () => { + stream.end(); +}); + From 975b96803481821b0c42f3b49518b642583985d0 Mon Sep 17 00:00:00 2001 From: curbengh <43627182+curbengh@users.noreply.github.com> Date: Fri, 9 Aug 2019 09:34:12 +0930 Subject: [PATCH 2/2] chore: include highlight_alias.json --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 99ad48e2..f7918edf 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ }, "files": [ "lib/", - "scripts/" + "scripts/", + "highlight_alias.json" ], "repository": "hexojs/hexo-util", "homepage": "https://hexo.io/",