This repository was archived by the owner on Sep 29, 2023. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2222 with :
2323 node-version : ${{ matrix.node-version }}
2424 - run : npm install
25- - run : npm run build
2625 - run : npm test
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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" ,
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments