Skip to content

Commit

Permalink
Add "sanity-check" package script
Browse files Browse the repository at this point in the history
Run docs in travis build and precommit
Fix type check errors
  • Loading branch information
Rob Walch committed Oct 15, 2019
1 parent 09797f5 commit 7f1c09e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"lint:quiet": "./scripts/lint.sh --quiet",
"precommit": "./scripts/precommit.sh",
"pretest": "npm run lint",
"sanity-check": "npm run lint && npm run docs && npm run type-check && npm run build:types && npm run build && npm run test:unit",
"start": "npm run dev",
"test": "npm run test:unit && npm run test:func",
"test:unit": "karma start karma.conf.js",
Expand Down
5 changes: 4 additions & 1 deletion scripts/precommit.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/bin/bash
npm run lint
set -e

npm run lint
npm run type-check
npm run docs
5 changes: 5 additions & 0 deletions scripts/travis.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ if [ "${TRAVIS_MODE}" = "build" ]; then
npm run lint
echo "travis_fold:end:lint"
echo "travis_fold:start:build"
npm run type-check
npm run build
npm run build:types
echo "travis_fold:end:build"
echo "travis_fold:start:docs"
npm run docs
Expand Down Expand Up @@ -47,7 +49,10 @@ elif [ "${TRAVIS_MODE}" = "release" ] || [ "${TRAVIS_MODE}" = "releaseCanary" ]
fi
node ./scripts/set-package-version.js
npm run lint
npm run type-check
npm run build:ci
npm run build:types

if [ "${TRAVIS_MODE}" != "netlifyPr" ]; then
npm run test:unit
if [[ $(node ./scripts/check-already-published.js) = "not published" ]]; then
Expand Down
2 changes: 1 addition & 1 deletion src/controller/audio-track-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class AudioTrackController extends TaskLoop {
*
* Set-up metadata update interval task for live-mode streams.
*
* @param {} data
* @param {*} data
*/
onAudioTrackLoaded (data) {
if (data.id >= this.tracks.length) {
Expand Down
15 changes: 5 additions & 10 deletions src/controller/timeline-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TimelineController extends EventHandler {
private cueRanges: Array<any> = [];
private captionsTracks: any = {};
private captionsProperties: any;
private cea608Parser: Cea608Parser;
private cea608Parser!: Cea608Parser;
private lastSn: number = -1;
private prevCC: number = -1;
private vttCCs: any = null;
Expand All @@ -34,7 +34,6 @@ class TimelineController extends EventHandler {
Event.MANIFEST_LOADING,
Event.MANIFEST_LOADED,
Event.FRAG_LOADED,
Event.LEVEL_SWITCHING,
Event.INIT_PTS_FOUND);

this.hls = hls;
Expand Down Expand Up @@ -129,7 +128,7 @@ class TimelineController extends EventHandler {
} else {
captionsTracks[trackName] = existingTrack;
clearCurrentCues(captionsTracks[trackName]);
sendAddTrackEvent(captionsTracks[trackName], media);
sendAddTrackEvent(captionsTracks[trackName], media as HTMLMediaElement);
}
}
}
Expand Down Expand Up @@ -199,7 +198,7 @@ class TimelineController extends EventHandler {
this.tracks.forEach((track, index) => {
let textTrack;
if (index < inUseTracks.length) {
let inUseTrack = null;
let inUseTrack: TextTrack | null = null;

for (let i = 0; i < inUseTracks.length; i++) {
if (canReuseVttTextTrack(inUseTracks[i], track)) {
Expand Down Expand Up @@ -228,10 +227,6 @@ class TimelineController extends EventHandler {
}
}

onLevelSwitching () {
this.enabled = this.hls.currentLevel.closedCaptions !== 'NONE';
}

onFragLoaded (data: { frag: Fragment, payload: any }) {
const { frag, payload } = data;
const { cea608Parser, initPTS, lastSn, unparsedVttFrags } = this;
Expand Down Expand Up @@ -324,7 +319,7 @@ class TimelineController extends EventHandler {
}

onFragParsingUserdata (data: { samples: Array<any> }) {
if (!this.enabled || !this.config.enableCEA708Captions) {
if (!this.enabled || !this.cea608Parser) {
return;
}

Expand All @@ -343,7 +338,7 @@ class TimelineController extends EventHandler {
let count = byteArray[0] & 31;
let position = 2;
let tmpByte, ccbyte1, ccbyte2, ccValid, ccType;
let actualCCBytes = [];
let actualCCBytes: number[] = [];

for (let j = 0; j < count; j++) {
tmpByte = byteArray[position++];
Expand Down
2 changes: 1 addition & 1 deletion src/loader/m3u8-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default class M3U8Parser {

if (audioGroups.length) {
// If there are audio groups signalled in the manifest, let's look for a matching codec string for this track
const groupCodec = M3U8Parser.findGroup(audioGroups, media.groupId);
const groupCodec = M3U8Parser.findGroup(audioGroups, media.groupId as string);

// If we don't find the track signalled, lets use the first audio groups codec we have
// Acting as a best guess
Expand Down
8 changes: 4 additions & 4 deletions tests/unit/controller/ewma-bandwidth-estimator.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ describe('EwmaBandWidthEstimator', function () {
bwEstimator.sample(8000, 1000000);
expect(bwEstimator.getEstimate()).to.equal(1000000);
bwEstimator.sample(4000, 1000000);
expect(bwEstimator.getEstimate()).to.equal(1396480.1544736226);
expect(bwEstimator.getEstimate()).to.closeTo(1396480.1544736226, 0.000000001);
bwEstimator.sample(1000, 1000000);
expect(bwEstimator.getEstimate()).to.equal(2056826.9489827948);
expect(bwEstimator.getEstimate()).to.closeTo(2056826.9489827948, 0.000000001);
});

it('returns correct value bitrate is slow=9,fast=5', function () {
Expand All @@ -36,8 +36,8 @@ describe('EwmaBandWidthEstimator', function () {
bwEstimator.sample(8000, 1000000);
expect(bwEstimator.getEstimate()).to.equal(1000000);
bwEstimator.sample(4000, 1000000);
expect(bwEstimator.getEstimate()).to.equal(1439580.319105247);
expect(bwEstimator.getEstimate()).to.closeTo(1439580.319105247, 0.000000001);
bwEstimator.sample(1000, 1000000);
expect(bwEstimator.getEstimate()).to.equal(2208342.324322311);
expect(bwEstimator.getEstimate()).to.closeTo(2208342.324322311, 0.000000001);
});
});

0 comments on commit 7f1c09e

Please sign in to comment.