Skip to content

Commit

Permalink
Chore: Fix/remove tools (fixes #471) (#476)
Browse files Browse the repository at this point in the history
* Chore: Fix/remove tools (fixes #471)

* Update tests tools
  • Loading branch information
nzakas authored Apr 21, 2021
1 parent 671c3aa commit 651e204
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 526 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"unit": "npm-run-all -s unit:*",
"unit:esm": "nyc mocha --color --reporter progress --timeout 30000 'tests/lib/**/*.js'",
"unit:cjs": "mocha --color --reporter progress --timeout 30000 tests/lib/commonjs.cjs",
"generate-regex": "node tools/generate-identifier-regex.js",
"test": "npm-run-all -p unit lint",
"lint": "eslint \"*.?(c)js\" lib/ tests/lib/",
"fixlint": "npm run lint -- --fix",
Expand Down
15 changes: 0 additions & 15 deletions tools/convert.js

This file was deleted.

23 changes: 14 additions & 9 deletions tools/create-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
* @author Nicholas C. Zakas
*/

"use strict";

/*
* Usage:
* node tools/create-test.js ecma-features/binaryLiterals/ file_with_code.js
Expand All @@ -16,14 +14,16 @@
// Requirements
//------------------------------------------------------------------------------

var shelljs = require("shelljs"),
espree = require("../espree"),
path = require("path");
import shelljs from "shelljs";
import { parse } from "../espree.js"
import path from "path";
import { fileURLToPath } from "url";

//------------------------------------------------------------------------------
// Initialization
//------------------------------------------------------------------------------

const __dirname = path.dirname(fileURLToPath(import.meta.url));
var PATTERN = /\/\*!espree\-section:\s*[a-z\d\-]+\*\//gi;

var filename = process.argv[2],
Expand Down Expand Up @@ -56,8 +56,8 @@ if (!sections || sections.length !== code.length) {
code.forEach(function(source, index) {

var fullFilename = filename + "/" + (sections[index].substring(18, sections[index].length - 2).trim()),
testSourceFilename = path.resolve("__dirname", "../tests/fixtures/" + fullFilename + ".src.js"),
testResultFilename = path.resolve("__dirname", "../tests/fixtures/" + fullFilename + ".result.js");
testSourceFilename = path.resolve(__dirname, "../tests/fixtures/" + fullFilename + ".src.js"),
testResultFilename = path.resolve(__dirname, "../tests/fixtures/" + fullFilename + ".result.js");

var result,
sourceCode = source.trim();
Expand All @@ -72,7 +72,7 @@ code.forEach(function(source, index) {
//------------------------------------------------------------------------------

try {
result = espree.parse(sourceCode, {
result = parse(sourceCode, {
ecmaVersion: 8, // change as needed
ecmaFeatures: {
experimentalObjectRestSpread: true
Expand All @@ -94,7 +94,12 @@ code.forEach(function(source, index) {
recursivelyRemoveStartAndEnd(result)

sourceCode.to(testSourceFilename);
("module.exports = " + JSON.stringify(result, null, " ")).to(testResultFilename);

let resultCode = `export default ${JSON.stringify(result, (key, value) => {
return (typeof value === "bigint") ? `bigint<${value}n>` : value;
}, 4)};`;
resultCode = resultCode.replace(/"bigint<(\d+n)>"/g, "$1");
resultCode.to(testResultFilename);
});

// acorn adds these "start" and "end" properties
Expand Down
52 changes: 0 additions & 52 deletions tools/generate-identifier-regex.js

This file was deleted.

Loading

0 comments on commit 651e204

Please sign in to comment.