regexp-generator: Use ES modules, update dependencies

This code hasn't been touched in a while, so it's probably good to bring
in the newest versions of the dependencies. We can easily tell if there
was any incompatible effect on the output.

The latest version of filenamify requires using ES modules. We also have
to adapt to a breaking change in regexpu-core (see
https://github.com/mathiasbynens/regexpu-core/pull/49).

Also convert the dependencies to devDependencies, since this tool is not
necessary for executing test262.
This commit is contained in:
Philip Chimento 2024-11-01 16:34:14 -07:00 committed by Philip Chimento
parent 754ecf1ad3
commit 879326855b
3 changed files with 16 additions and 17 deletions

View File

@ -1,4 +1,4 @@
module.exports = description => { export default description => {
let header = `// Copyright (C) 2018 Leo Balter. All rights reserved. let header = `// Copyright (C) 2018 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file. // This code is governed by the BSD license found in the LICENSE file.

View File

@ -1,9 +1,10 @@
const fs = require('fs'); import filenamify from 'filenamify';
const rewritePattern = require('regexpu-core'); import fs from 'node:fs';
const slugify = require('slugify'); import jsesc from 'jsesc';
const filenamify = require('filenamify'); import rewritePattern from 'regexpu-core';
const jsesc = require('jsesc'); import slugify from 'slugify';
const header = require('./header');
import header from './header.mjs';
const patterns = { const patterns = {
'whitespace class escape': '\\s', 'whitespace class escape': '\\s',
@ -91,7 +92,7 @@ for (const [desc, escape] of Object.entries(patterns)) {
const pattern = `${escape}${quantifier}`; const pattern = `${escape}${quantifier}`;
const range = rewritePattern(pattern, flags, { const range = rewritePattern(pattern, flags, {
useUnicodeFlag: flags.includes('u') unicodeFlag: flags.includes('u') ? 'transform' : false,
}); });
console.log(`${pattern} => ${range}, flags: ${flags}`); console.log(`${pattern} => ${range}, flags: ${flags}`);

View File

@ -2,23 +2,21 @@
"name": "test262-regexp-class-escapes", "name": "test262-regexp-class-escapes",
"version": "1.0.0", "version": "1.0.0",
"description": "", "description": "",
"main": "index.js", "main": "index.mjs",
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1", "test": "echo \"Error: no test specified\" && exit 1",
"clean": "rimraf ../../test/built-ins/RegExp/CharacterClassEscapes", "clean": "rimraf ../../test/built-ins/RegExp/CharacterClassEscapes",
"prebuild": "mkdirp ../../test/built-ins/RegExp/CharacterClassEscapes", "prebuild": "mkdirp ../../test/built-ins/RegExp/CharacterClassEscapes",
"build": "node index.js" "build": "node index.mjs"
}, },
"author": "", "author": "",
"license": "MIT", "license": "MIT",
"dependencies": {
"filenamify": "^2.1.0",
"jsesc": "^2.5.1",
"regexpu-core": "^4.2.0",
"slugify": "^1.3.0"
},
"devDependencies": { "devDependencies": {
"filenamify": "^6.0.0",
"jsesc": "^3.0.2",
"mkdirp": "^3.0.1", "mkdirp": "^3.0.1",
"rimraf": "^6.0.1" "regexpu-core": "^6.1.1",
"rimraf": "^6.0.1",
"slugify": "^1.6.6"
} }
} }