Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git-node: implement --commit option of git node wpt #416

Merged
merged 1 commit into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions components/git/wpt.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ function builder(yargs) {
type: 'string'
})
.options({
commit: {
describe: 'A specific commit the subset should be updated to',
type: 'string',
default: undefined
},
nodedir: {
describe: 'Path to the node.js project directory',
type: 'string',
Expand All @@ -28,7 +33,7 @@ function builder(yargs) {
}

async function main(argv) {
const { name, nodedir } = argv;
const { name, nodedir, commit } = argv;
const cli = new CLI();
const credentials = await auth({
github: true
Expand All @@ -47,21 +52,22 @@ async function main(argv) {
}

if (name === 'all' || name === 'resources') {
updaters.push(new ResourcesUpdater(cli, request, nodedir));
updaters.push(new ResourcesUpdater(cli, request, nodedir, commit));
}
if (name === 'all' || name === 'interfaces') {
updaters.push(new InterfacesUpdater(cli, request, nodedir, supported));
updaters.push(new InterfacesUpdater(cli, request, nodedir,
commit, supported));
}

if (name === 'all') {
for (const item of supported) {
updaters.push(new WPTUpdater(item, cli, request, nodedir));
updaters.push(new WPTUpdater(item, cli, request, nodedir, commit));
}
} else if (name !== 'resources' && name !== 'interfaces') {
if (!supported.includes(name)) {
cli.warn(`Please create ${name}.json in ${statusFolder}`);
}
updaters.push(new WPTUpdater(name, cli, request, nodedir));
updaters.push(new WPTUpdater(name, cli, request, nodedir, commit));
}

for (const updater of updaters) {
Expand Down
17 changes: 17 additions & 0 deletions docs/git-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -375,11 +375,28 @@ to the assets, this also updates:
- `./test/fixtures/wpt/README.md`
- `./test/fixtures/wpt/LICENSE.md`

```
git-node wpt <name>

Updates WPT suite

Positionals:
name Subset of the WPT to update [string] [required]

Options:
--version Show version number [boolean]
--help Show help [boolean]
--commit A specific commit the subset should be updated to [string]
--nodedir Path to the node.js project directory [string] [default: "."]
```

### Example

```
$ cd /path/to/node/project
$ git node wpt url # Will update test/fixtures/wpt/url and related files
# Will update test/fixtures/wpt/url and related files to the specified commit
$ git node wpt url --commit=43feb7f612fe9160639e09a47933a29834904d69
```

[node.js abi version registry]: https://github.com/nodejs/node/blob/master/doc/abi_version_registry.json
13 changes: 7 additions & 6 deletions lib/wpt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const {
} = require('../utils');

class WPTUpdater {
constructor(path, cli, request, nodedir) {
constructor(path, cli, request, nodedir, commit) {
this.path = path;
this.nodedir = nodedir;

Expand All @@ -19,7 +19,8 @@ class WPTUpdater {
owner: 'web-platform-tests',
repo: 'wpt',
branch: 'master',
path
path,
commit
};
this.tree = new GitHubTree(cli, request, this.treeParams);
this.assets = [];
Expand Down Expand Up @@ -162,8 +163,8 @@ class WPTUpdater {
}

class ResourcesUpdater extends WPTUpdater {
constructor(cli, request, nodedir) {
super('resources', cli, request, nodedir);
constructor(cli, request, nodedir, commit) {
super('resources', cli, request, nodedir, commit);
}

async update() { // override
Expand Down Expand Up @@ -194,8 +195,8 @@ class ResourcesUpdater extends WPTUpdater {
}

class InterfacesUpdater extends WPTUpdater {
constructor(cli, request, nodedir, supported) {
super('interfaces', cli, request, nodedir);
constructor(cli, request, nodedir, commit, supported) {
super('interfaces', cli, request, nodedir, commit);
this.supported = supported;
}

Expand Down