diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-11-05 15:53:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-05 15:53:21 +0100 |
commit | 791119d4af1066b20fa2b5bf8fc82d04d843d51d (patch) | |
tree | 94890756f4380fb2c1d8abd92af66128533a1535 /tools/build_benchmark_jsons.js | |
parent | e7cfd90b0f72874aa1535a382df32dce28bd587a (diff) |
build: rewrite tools/ scripts to deno (#8247)
This commit rewrites scripts in "tools/" directory
to use Deno instead of Python. In return it allows
to remove huge number of Python packages in "third_party/".
Diffstat (limited to 'tools/build_benchmark_jsons.js')
-rw-r--r-- | tools/build_benchmark_jsons.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/build_benchmark_jsons.js b/tools/build_benchmark_jsons.js new file mode 100644 index 000000000..af43226d7 --- /dev/null +++ b/tools/build_benchmark_jsons.js @@ -0,0 +1,31 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. +import { buildPath, existsSync, join } from "./util.js"; + +const currentDataFile = join(buildPath(), "bench.json"); +const allDataFile = "gh-pages/data.json"; // Includes all benchmark data. +const recentDataFile = "gh-pages/recent.json"; // Includes recent 20 benchmark data. + +function readJson(filename) { + return JSON.parse(Deno.readTextFileSync(filename)); +} + +function writeJson(filename, data) { + return Deno.writeTextFileSync(filename, JSON.stringify(data)); +} + +if (!existsSync(currentDataFile)) { + throw new Error(`${currentDataFile} doesn't exist`); +} + +if (!existsSync(allDataFile)) { + throw new Error(`${allDataFile} doesn't exist`); +} + +const newData = readJson(currentDataFile); +const allData = readJson(allDataFile); +allData.push(newData); +const allDataLen = allData.length; +const recentData = allData.slice(allDataLen - 20); + +writeJson(allDataFile, allData); +writeJson(recentDataFile, recentData); |