Skip to content
This repository was archived by the owner on Sep 29, 2023. It is now read-only.

Commit c1aa98e

Browse files
authored
Cleanup (#2)
1 parent 133f9ec commit c1aa98e

File tree

10 files changed

+57
-120
lines changed

10 files changed

+57
-120
lines changed

.editorconfig

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,4 @@ jobs:
2222
with:
2323
node-version: ${{ matrix.node-version }}
2424
- run: npm install
25-
- run: npm run build
2625
- run: npm test

.travis.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
## Installation
66

7-
Only supported on Node >=v4.2 because of promise support.
8-
9-
If support is desired for earlier versions, a global promise polyfill is required.
7+
Only supported on Node >= 10
108

119
```bash
1210
$ npm install --save gitcloud

gitcloud.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const axios = require('axios');
2+
const cheerio = require('cheerio');
3+
4+
function gitCloud(pageUrl) {
5+
return axios.get(pageUrl)
6+
.then(function (response) {
7+
const $ = cheerio.load(response.data);
8+
9+
const fileIndex = $('#file-index').find('a').map((index, element) => {
10+
const elementJq = $(element);
11+
return {
12+
name: elementJq.text(),
13+
url: elementJq.attr('href')
14+
};
15+
}).get();
16+
17+
return fileIndex;
18+
});
19+
}
20+
21+
module.exports = gitCloud;

package.json

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,27 @@
11
{
22
"name": "gitcloud",
3-
"version": "0.1.3",
3+
"version": "0.2.0",
4+
"engines": {
5+
"node": ">= 10.0.0",
6+
"npm": ">= 6.0.0"
7+
},
48
"description": "Client for GitCloud",
5-
"main": "lib/index.js",
9+
"main": "gitcloud.js",
610
"directories": {
711
"test": "test"
812
},
913
"scripts": {
10-
"build": "babel src -d lib --source-maps",
11-
"watch": "babel src -d lib --source-maps --watch",
12-
"test": "npm run build && mocha --compilers js:babel-register"
14+
"test": "mocha"
1315
},
1416
"author": "Goh Jia Hao",
1517
"license": "MIT",
1618
"dependencies": {
17-
"axios": "^0.21.0",
18-
"cheerio": "^0.20.0",
19-
"source-map-support": "^0.4.0"
19+
"axios": "^0.21.1",
20+
"cheerio": "^1.0.0-rc.5"
2021
},
2122
"devDependencies": {
22-
"babel-cli": "^6.6.4",
23-
"babel-preset-es2015": "^6.6.0",
24-
"babel-register": "^6.6.0",
25-
"chai": "^3.5.0",
26-
"mocha": "^2.4.5"
27-
},
28-
"babel": {
29-
"presets": [
30-
"es2015"
31-
]
23+
"chai": "^4.3.0",
24+
"mocha": "^8.3.0"
3225
},
3326
"repository": {
3427
"type": "git",

src/gitCloud.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/index.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

test/gitCloud.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

test/gitcloud.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const chai = require('chai');
2+
const gitCloud = require('../gitcloud');
3+
4+
function checkIndex(index) {
5+
const containsCat = index.some(element => {
6+
return element.url.includes('/cat');
7+
});
8+
9+
chai.expect(containsCat).to.be.equal(true, 'One of the paths should contain"/cat"');
10+
}
11+
12+
describe('GitCloud Client', function () {
13+
this.timeout(10000);
14+
15+
it('Gets the index', function (done) {
16+
gitCloud('https://jiahaog.github.io/gitcloud')
17+
.then(fileIndex => {
18+
checkIndex(fileIndex);
19+
done()
20+
})
21+
.catch(done);
22+
})
23+
24+
});

0 commit comments

Comments
 (0)