Skip to content

Commit c8c7d77

Browse files
committed
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 mathiasbynens/regexpu-core#49). Also convert the dependencies to devDependencies, since this tool is not necessary for executing test262.
1 parent 5294ed5 commit c8c7d77

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

tools/regexp-generator/header.js renamed to tools/regexp-generator/header.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module.exports = description => {
1+
export default description => {
22
let header = `// Copyright (C) 2018 Leo Balter. All rights reserved.
33
// This code is governed by the BSD license found in the LICENSE file.
44

tools/regexp-generator/index.js renamed to tools/regexp-generator/index.mjs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const fs = require('fs');
2-
const rewritePattern = require('regexpu-core');
3-
const slugify = require('slugify');
4-
const filenamify = require('filenamify');
5-
const jsesc = require('jsesc');
6-
const header = require('./header');
1+
import filenamify from 'filenamify';
2+
import fs from 'node:fs';
3+
import jsesc from 'jsesc';
4+
import rewritePattern from 'regexpu-core';
5+
import slugify from 'slugify';
6+
7+
import header from './header.mjs';
78

89
const patterns = {
910
'whitespace class escape': '\\s',
@@ -91,7 +92,7 @@ for (const [desc, escape] of Object.entries(patterns)) {
9192

9293
const pattern = `${escape}${quantifier}`;
9394
const range = rewritePattern(pattern, flags, {
94-
useUnicodeFlag: flags.includes('u')
95+
unicodeFlag: flags.includes('u') ? 'transform' : false,
9596
});
9697

9798
console.log(`${pattern} => ${range}, flags: ${flags}`);

tools/regexp-generator/package.json

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,21 @@
22
"name": "test262-regexp-class-escapes",
33
"version": "1.0.0",
44
"description": "",
5-
"main": "index.js",
5+
"main": "index.mjs",
66
"scripts": {
77
"test": "echo \"Error: no test specified\" && exit 1",
88
"clean": "rimraf ../../test/built-ins/RegExp/CharacterClassEscapes",
99
"prebuild": "mkdirp ../../test/built-ins/RegExp/CharacterClassEscapes",
10-
"build": "node index.js"
10+
"build": "node index.mjs"
1111
},
1212
"author": "",
1313
"license": "MIT",
14-
"dependencies": {
15-
"filenamify": "^2.1.0",
16-
"jsesc": "^2.5.1",
17-
"regexpu-core": "^4.2.0",
18-
"slugify": "^1.3.0"
19-
},
2014
"devDependencies": {
15+
"filenamify": "^6.0.0",
16+
"jsesc": "^3.0.2",
2117
"mkdirp": "^3.0.1",
22-
"rimraf": "^6.0.1"
18+
"regexpu-core": "^6.1.1",
19+
"rimraf": "^6.0.1",
20+
"slugify": "^1.6.6"
2321
}
2422
}

0 commit comments

Comments
 (0)