Skip to content

Commit 5d4b7cc

Browse files
authored
Merge pull request #8 from pkgjs/rename
Rename to detect-node-support
2 parents a5c8a6d + e2240b4 commit 5d4b7cc

File tree

6 files changed

+75
-68
lines changed

6 files changed

+75
-68
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
# node-support
1+
# detect-node-support
22

33
List the Node.js versions supported by the package/repository
44

55
## Usage (command line)
66

77
```
8-
$ npx node-support [path]
8+
$ npx detect-node-support [path]
99
```
1010

1111
Prints the supported Node.js versions for the package at the specified path. When the path is not a git repository - tries to read the git repository from `package.json` and tries to detect the versions listed in the repository as well.
1212

1313
When `path` is omitted, tries to detect the versions for `cwd`.
1414

1515
```
16-
$ npx node-support [package name]
16+
$ npx detect-node-support [package name]
1717
```
1818

1919
Prints supported Node.js versions for the package from the registry.
2020

2121
```
22-
$ npx node-support [repository git URL]
22+
$ npx detect-node-support [repository git URL]
2323
```
2424

2525
Prints supported Node.js versions for the package at the git URL.
2626

2727
## Usage (library)
2828

2929
```
30-
const result = await require('node-support').detect({ path });
30+
const result = await require('detect-node-support').detect({ path });
3131
```
3232

3333
`path` should be a folder in the local file system. When the path is not a git repository - tries to read the git repository from `package.json` and tries to detect the versions listed in the repository as well.
3434

3535
```
36-
const result = await require('node-support').detect({ packageName });
36+
const result = await require('detect-node-support').detect({ packageName });
3737
```
3838

3939
`packageName` is a string name for the package in the registry.
4040

4141
```
42-
const result = await require('node-support').detect({ repository });
42+
const result = await require('detect-node-support').detect({ repository });
4343
```
4444

4545
`repository` is a URL for a git repository.
File renamed without changes.

lib/loader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ internals.createRepositoryLoader = (repository) => {
8181
loadFile: async (filename, options) => {
8282

8383
if (parsedRepository.source !== 'github.com') {
84-
throw new Error('Only github.com paths supported, feel free to PR at https://github.com/pkgjs/node-support');
84+
throw new Error('Only github.com paths supported, feel free to PR at https://github.com/pkgjs/detect-node-support');
8585
}
8686

8787
const url = `https://raw.githubusercontent.com/${parsedRepository.full_name}/HEAD/${filename}`;

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
{
2-
"name": "node-support",
2+
"name": "detect-node-support",
33
"version": "0.0.0-development",
44
"description": "List the Node.js versions supported by the package/repository",
55
"main": "lib/index.js",
66
"scripts": {
7-
"test-cli": " while read p; do echo \"./bin/node-support $p\"; ./bin/node-support $p; done < ./test/cli-test.txt",
8-
"test": "lab -a @hapi/code -L -p 1 -t 100"
7+
"test-cli": " while read p; do echo \"./bin/detect-node-support $p\"; ./bin/detect-node-support $p; done < ./test/cli-test.txt",
8+
"test": "lab -a @hapi/code -L -p 1 -t 100 -m 5000"
99
},
1010
"repository": {
1111
"type": "git",
12-
"url": "git+https://github.com/pkgjs/node-support.git"
12+
"url": "git+https://github.com/pkgjs/detect-node-support.git"
1313
},
1414
"author": "Dominykas Blyžė <[email protected]>",
1515
"license": "MIT",
1616
"bugs": {
17-
"url": "https://github.com/pkgjs/node-support/issues"
17+
"url": "https://github.com/pkgjs/detect-node-support/issues"
1818
},
1919
"engines": {
2020
"node": ">=10"
2121
},
22-
"homepage": "https://github.com/pkgjs/node-support#readme",
22+
"homepage": "https://github.com/pkgjs/detect-node-support#readme",
2323
"devDependencies": {
2424
"@hapi/code": "^7.0.0",
2525
"@hapi/lab": "^21.0.0",

test/cli-test.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
.
3-
node-support
3+
detect-node-support
44
@hapi/hapi
5-
pkgjs/node-support
6-
https://github.com/pkgjs/node-support
7-
git+https://github.com/pkgjs/node-support.git
5+
pkgjs/detect-node-support
6+
https://github.com/pkgjs/detect-node-support
7+
git+https://github.com/pkgjs/detect-node-support.git

test/index.js

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ internals.assertCommit = (result) => {
5555
delete result.commit;
5656
};
5757

58-
describe('node-support', () => {
58+
describe('detect-node-support', () => {
5959

6060
let listRemoteStub;
6161

@@ -79,6 +79,8 @@ describe('node-support', () => {
7979
Nock.activate();
8080
}
8181

82+
Nock.disableNetConnect();
83+
8284
Nock('https://raw.githubusercontent.com')
8385
.persist()
8486
.get('/nodejs/Release/master/schedule.json')
@@ -103,6 +105,7 @@ describe('node-support', () => {
103105

104106
Nock.restore();
105107
Nock.cleanAll();
108+
Nock.enableNetConnect();
106109
});
107110

108111
describe('detect()', () => {
@@ -118,7 +121,7 @@ describe('node-support', () => {
118121
internals.assertCommit(result);
119122

120123
expect(result).to.equal({
121-
name: 'node-support',
124+
name: 'detect-node-support',
122125
version: '0.0.0-development',
123126
timestamp: 1580673602000,
124127
travis: {
@@ -468,18 +471,18 @@ describe('node-support', () => {
468471
.returns('9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n');
469472

470473
Nock('https://raw.githubusercontent.com')
471-
.get('/pkgjs/node-support/HEAD/package.json')
474+
.get('/pkgjs/detect-node-support/HEAD/package.json')
472475
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', 'package.json')))
473-
.get('/pkgjs/node-support/HEAD/.travis.yml')
476+
.get('/pkgjs/detect-node-support/HEAD/.travis.yml')
474477
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', '.travis.yml')));
475478

476-
const result = await NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/node-support.git' });
479+
const result = await NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/detect-node-support.git' });
477480

478481
expect(listRemoteStub.callCount).to.equal(1);
479-
expect(listRemoteStub.args[0]).to.equal([['http://github.com/pkgjs/node-support.git', 'HEAD']]);
482+
expect(listRemoteStub.args[0]).to.equal([['http://github.com/pkgjs/detect-node-support.git', 'HEAD']]);
480483

481484
expect(result).to.equal({
482-
name: 'node-support',
485+
name: 'detect-node-support',
483486
version: '0.0.0-development',
484487
commit: '9cef39d21ad229dea4b10295f55b0d9a83800b23',
485488
timestamp: 1580673602000,
@@ -501,24 +504,24 @@ describe('node-support', () => {
501504
.returns('9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n');
502505

503506
Nock('https://raw.githubusercontent.com')
504-
.get('/pkgjs/node-support/HEAD/package.json')
507+
.get('/pkgjs/detect-node-support/HEAD/package.json')
505508
.reply(404)
506-
.get('/pkgjs/node-support/HEAD/.travis.yml')
509+
.get('/pkgjs/detect-node-support/HEAD/.travis.yml')
507510
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', '.travis.yml')));
508511

509-
await expect(NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/node-support.git' }))
510-
.to.reject(`git+https://github.com/pkgjs/node-support.git does not contain a package.json`);
512+
await expect(NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/detect-node-support.git' }))
513+
.to.reject(`git+https://github.com/pkgjs/detect-node-support.git does not contain a package.json`);
511514
});
512515

513516
it('rethrows server errors', async () => {
514517

515518
Nock('https://raw.githubusercontent.com')
516-
.get('/pkgjs/node-support/HEAD/package.json')
519+
.get('/pkgjs/detect-node-support/HEAD/package.json')
517520
.reply(500)
518-
.get('/pkgjs/node-support/HEAD/.travis.yml')
521+
.get('/pkgjs/detect-node-support/HEAD/.travis.yml')
519522
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', '.travis.yml')));
520523

521-
await expect(NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/node-support.git' }))
524+
await expect(NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/detect-node-support.git' }))
522525
.to.reject(/Response Error/);
523526
});
524527

@@ -528,14 +531,14 @@ describe('node-support', () => {
528531

529532
Sinon.stub(Wreck, 'get').throws(err);
530533

531-
await expect(NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/node-support.git' }))
534+
await expect(NodeSupport.detect({ repository: 'git+https://github.com/pkgjs/detect-node-support.git' }))
532535
.to.reject('Something went wrong');
533536
});
534537

535538
it('throws when a package does not live on public github.com', async () => {
536539

537-
await expect(NodeSupport.detect({ repository: 'git+https://github.example.com/pkgjs/node-support.git' }))
538-
.to.reject('Only github.com paths supported, feel free to PR at https://github.com/pkgjs/node-support');
540+
await expect(NodeSupport.detect({ repository: 'git+https://github.example.com/pkgjs/detect-node-support.git' }))
541+
.to.reject('Only github.com paths supported, feel free to PR at https://github.com/pkgjs/detect-node-support');
539542
});
540543
});
541544

@@ -547,22 +550,22 @@ describe('node-support', () => {
547550
.returns('9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n');
548551

549552
Nock('https://raw.githubusercontent.com')
550-
.get('/pkgjs/node-support/HEAD/package.json')
553+
.get('/pkgjs/detect-node-support/HEAD/package.json')
551554
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', 'package.json')))
552-
.get('/pkgjs/node-support/HEAD/.travis.yml')
555+
.get('/pkgjs/detect-node-support/HEAD/.travis.yml')
553556
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', '.travis.yml')));
554557

555558
Nock('https://registry.npmjs.org')
556-
.get('/node-support')
559+
.get('/detect-node-support')
557560
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', 'package.json')));
558561

559-
const result = await NodeSupport.detect({ packageName: 'node-support' });
562+
const result = await NodeSupport.detect({ packageName: 'detect-node-support' });
560563

561564
expect(listRemoteStub.callCount).to.equal(1);
562-
expect(listRemoteStub.args[0]).to.equal([['http://github.com/pkgjs/node-support.git', 'HEAD']]);
565+
expect(listRemoteStub.args[0]).to.equal([['http://github.com/pkgjs/detect-node-support.git', 'HEAD']]);
563566

564567
expect(result).to.equal({
565-
name: 'node-support',
568+
name: 'detect-node-support',
566569
version: '0.0.0-development',
567570
commit: '9cef39d21ad229dea4b10295f55b0d9a83800b23',
568571
timestamp: 1580673602000,
@@ -581,51 +584,55 @@ describe('node-support', () => {
581584
it('throws when package does not exist in the registry', async () => {
582585

583586
Nock('https://registry.npmjs.org')
584-
.get('/node-support')
587+
.get('/detect-node-support')
585588
.reply(404);
586589

587-
await expect(NodeSupport.detect({ packageName: 'node-support' }))
588-
.to.reject(`Package node-support does not exist`);
590+
await expect(NodeSupport.detect({ packageName: 'detect-node-support' }))
591+
.to.reject(`Package detect-node-support does not exist`);
589592
});
590593

591594
it('rethrows registry server errors', async () => {
592595

593596
Nock('https://registry.npmjs.org')
594-
.get('/node-support')
597+
.get('/detect-node-support')
595598
.reply(500);
596599

597-
await expect(NodeSupport.detect({ packageName: 'node-support' }))
600+
await expect(NodeSupport.detect({ packageName: 'detect-node-support' }))
598601
.to.reject(/Internal Server Error/);
599602
});
600603

601604
it('rethrows generic errors', async () => {
602605

606+
Nock('https://registry.npmjs.org')
607+
.get('/detect-node-support')
608+
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', 'package.json')));
609+
603610
const err = new Error('Something went wrong');
604611

605612
Sinon.stub(Wreck, 'get').throws(err);
606613

607-
await expect(NodeSupport.detect({ packageName: 'node-support' }))
614+
await expect(NodeSupport.detect({ packageName: 'detect-node-support' }))
608615
.to.reject('Something went wrong');
609616
});
610617

611618
it('throws when packument does not contain a `repository` field', async () => {
612619

613620
Nock('https://registry.npmjs.org')
614-
.get('/node-support')
615-
.reply(200, JSON.stringify({ name: 'node-support' }));
621+
.get('/detect-node-support')
622+
.reply(200, JSON.stringify({ name: 'detect-node-support' }));
616623

617-
await expect(NodeSupport.detect({ packageName: 'node-support' }))
618-
.to.reject('Unable to determine the git repository for node-support');
624+
await expect(NodeSupport.detect({ packageName: 'detect-node-support' }))
625+
.to.reject('Unable to determine the git repository for detect-node-support');
619626
});
620627

621628
it('throws when packument does not contain a `repository.url` field', async () => {
622629

623630
Nock('https://registry.npmjs.org')
624-
.get('/node-support')
625-
.reply(200, JSON.stringify({ name: 'node-support', repository: {} }));
631+
.get('/detect-node-support')
632+
.reply(200, JSON.stringify({ name: 'detect-node-support', repository: {} }));
626633

627-
await expect(NodeSupport.detect({ packageName: 'node-support' }))
628-
.to.reject('Unable to determine the git repository for node-support');
634+
await expect(NodeSupport.detect({ packageName: 'detect-node-support' }))
635+
.to.reject('Unable to determine the git repository for detect-node-support');
629636
});
630637

631638
it('returns node versions from `.travis.yml` in the package repository (string repository)', async () => {
@@ -634,25 +641,25 @@ describe('node-support', () => {
634641
.returns('9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n');
635642

636643
Nock('https://raw.githubusercontent.com')
637-
.get('/pkgjs/node-support/HEAD/package.json')
644+
.get('/pkgjs/detect-node-support/HEAD/package.json')
638645
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', 'package.json')))
639-
.get('/pkgjs/node-support/HEAD/.travis.yml')
646+
.get('/pkgjs/detect-node-support/HEAD/.travis.yml')
640647
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', '.travis.yml')));
641648

642649
Nock('https://registry.npmjs.org')
643-
.get('/node-support')
650+
.get('/detect-node-support')
644651
.reply(200, JSON.stringify({
645-
name: 'node-support',
646-
repository: 'git+https://github.com/pkgjs/node-support.git'
652+
name: 'detect-node-support',
653+
repository: 'git+https://github.com/pkgjs/detect-node-support.git'
647654
}));
648655

649-
const result = await NodeSupport.detect({ packageName: 'node-support' });
656+
const result = await NodeSupport.detect({ packageName: 'detect-node-support' });
650657

651658
expect(listRemoteStub.callCount).to.equal(1);
652-
expect(listRemoteStub.args[0]).to.equal([['http://github.com/pkgjs/node-support.git', 'HEAD']]);
659+
expect(listRemoteStub.args[0]).to.equal([['http://github.com/pkgjs/detect-node-support.git', 'HEAD']]);
653660

654661
expect(result).to.equal({
655-
name: 'node-support',
662+
name: 'detect-node-support',
656663
version: '0.0.0-development',
657664
commit: '9cef39d21ad229dea4b10295f55b0d9a83800b23',
658665
timestamp: 1580673602000,
@@ -674,17 +681,17 @@ describe('node-support', () => {
674681
.returns('9cef39d21ad229dea4b10295f55b0d9a83800b23\tHEAD\n');
675682

676683
Nock('https://raw.githubusercontent.com')
677-
.get('/pkgjs/node-support/HEAD/package.json')
684+
.get('/pkgjs/detect-node-support/HEAD/package.json')
678685
.reply(200, JSON.stringify({ name: 'something-else' }))
679-
.get('/pkgjs/node-support/HEAD/.travis.yml')
686+
.get('/pkgjs/detect-node-support/HEAD/.travis.yml')
680687
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', '.travis.yml')));
681688

682689
Nock('https://registry.npmjs.org')
683-
.get('/node-support')
690+
.get('/detect-node-support')
684691
.reply(200, Fs.readFileSync(Path.join(__dirname, '..', 'package.json')));
685692

686-
await expect(NodeSupport.detect({ packageName: 'node-support' }))
687-
.to.reject('git+https://github.com/pkgjs/node-support.git does not contain node-support');
693+
await expect(NodeSupport.detect({ packageName: 'detect-node-support' }))
694+
.to.reject('git+https://github.com/pkgjs/detect-node-support.git does not contain detect-node-support');
688695
});
689696
});
690697
});

0 commit comments

Comments
 (0)