Skip to content

Commit ad3bd0c

Browse files
authored
git-node: implement --commit option of git node wpt (#416)
Add an option to explicitly specify the commit the WPT subset should be updated to instead of always using the latest commit.
1 parent 8e6ac47 commit ad3bd0c

File tree

3 files changed

+35
-11
lines changed

3 files changed

+35
-11
lines changed

components/git/wpt.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ function builder(yargs) {
1919
type: 'string'
2020
})
2121
.options({
22+
commit: {
23+
describe: 'A specific commit the subset should be updated to',
24+
type: 'string',
25+
default: undefined
26+
},
2227
nodedir: {
2328
describe: 'Path to the node.js project directory',
2429
type: 'string',
@@ -28,7 +33,7 @@ function builder(yargs) {
2833
}
2934

3035
async function main(argv) {
31-
const { name, nodedir } = argv;
36+
const { name, nodedir, commit } = argv;
3237
const cli = new CLI();
3338
const credentials = await auth({
3439
github: true
@@ -47,21 +52,22 @@ async function main(argv) {
4752
}
4853

4954
if (name === 'all' || name === 'resources') {
50-
updaters.push(new ResourcesUpdater(cli, request, nodedir));
55+
updaters.push(new ResourcesUpdater(cli, request, nodedir, commit));
5156
}
5257
if (name === 'all' || name === 'interfaces') {
53-
updaters.push(new InterfacesUpdater(cli, request, nodedir, supported));
58+
updaters.push(new InterfacesUpdater(cli, request, nodedir,
59+
commit, supported));
5460
}
5561

5662
if (name === 'all') {
5763
for (const item of supported) {
58-
updaters.push(new WPTUpdater(item, cli, request, nodedir));
64+
updaters.push(new WPTUpdater(item, cli, request, nodedir, commit));
5965
}
6066
} else if (name !== 'resources' && name !== 'interfaces') {
6167
if (!supported.includes(name)) {
6268
cli.warn(`Please create ${name}.json in ${statusFolder}`);
6369
}
64-
updaters.push(new WPTUpdater(name, cli, request, nodedir));
70+
updaters.push(new WPTUpdater(name, cli, request, nodedir, commit));
6571
}
6672

6773
for (const updater of updaters) {

docs/git-node.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,11 +375,28 @@ to the assets, this also updates:
375375
- `./test/fixtures/wpt/README.md`
376376
- `./test/fixtures/wpt/LICENSE.md`
377377

378+
```
379+
git-node wpt <name>
380+
381+
Updates WPT suite
382+
383+
Positionals:
384+
name Subset of the WPT to update [string] [required]
385+
386+
Options:
387+
--version Show version number [boolean]
388+
--help Show help [boolean]
389+
--commit A specific commit the subset should be updated to [string]
390+
--nodedir Path to the node.js project directory [string] [default: "."]
391+
```
392+
378393
### Example
379394

380395
```
381396
$ cd /path/to/node/project
382397
$ git node wpt url # Will update test/fixtures/wpt/url and related files
398+
# Will update test/fixtures/wpt/url and related files to the specified commit
399+
$ git node wpt url --commit=43feb7f612fe9160639e09a47933a29834904d69
383400
```
384401

385402
[node.js abi version registry]: https://github.com/nodejs/node/blob/master/doc/abi_version_registry.json

lib/wpt/index.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
} = require('../utils');
1010

1111
class WPTUpdater {
12-
constructor(path, cli, request, nodedir) {
12+
constructor(path, cli, request, nodedir, commit) {
1313
this.path = path;
1414
this.nodedir = nodedir;
1515

@@ -19,7 +19,8 @@ class WPTUpdater {
1919
owner: 'web-platform-tests',
2020
repo: 'wpt',
2121
branch: 'master',
22-
path
22+
path,
23+
commit
2324
};
2425
this.tree = new GitHubTree(cli, request, this.treeParams);
2526
this.assets = [];
@@ -162,8 +163,8 @@ class WPTUpdater {
162163
}
163164

164165
class ResourcesUpdater extends WPTUpdater {
165-
constructor(cli, request, nodedir) {
166-
super('resources', cli, request, nodedir);
166+
constructor(cli, request, nodedir, commit) {
167+
super('resources', cli, request, nodedir, commit);
167168
}
168169

169170
async update() { // override
@@ -194,8 +195,8 @@ class ResourcesUpdater extends WPTUpdater {
194195
}
195196

196197
class InterfacesUpdater extends WPTUpdater {
197-
constructor(cli, request, nodedir, supported) {
198-
super('interfaces', cli, request, nodedir);
198+
constructor(cli, request, nodedir, commit, supported) {
199+
super('interfaces', cli, request, nodedir, commit);
199200
this.supported = supported;
200201
}
201202

0 commit comments

Comments
 (0)