Skip to content

Commit

Permalink
Add padding-line-between-statements eslint rule
Browse files Browse the repository at this point in the history
  • Loading branch information
osk committed Oct 20, 2018
1 parent 0f9616e commit 071bd45
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 209 deletions.
9 changes: 7 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@
"always"
],
"space-infix-ops": 2,
"spaced-comment": 2
"spaced-comment": 2,
"padding-line-between-statements": [
"error",
{ "blankLine": "always", "prev": "block-like", "next": "*" },
{ "blankLine": "always", "prev": "*", "next": "block-like" }
]
}
}
}
7 changes: 7 additions & 0 deletions bin/webvtt-segment.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ try {
}

let playlist = '';

try {
log(`Creating playlist for "${input}" with ${t} sec segments`);
playlist = hls.hlsSegmentPlaylist(content, t);
Expand All @@ -56,6 +57,7 @@ try {

const playlistFilename = 'playlist.m3u8';
const target = path.join(outputDir, playlistFilename);

try {
log(`Writing ${playlist.length} bytes (utf-8) to "${playlistFilename}"`);
fs.writeFileSync(target, playlist, 'utf-8');
Expand All @@ -65,6 +67,7 @@ try {
}

let segments = [];

try {
log(`Segmenting "${input}" (${content.length} bytes) with ${t} sec segments`);
segments = hls.hlsSegment(content, t);
Expand All @@ -78,13 +81,15 @@ log(`Writing ${n} segments`);
segments.forEach((segment, i) => {
const filename = segment.filename;
const targetFile = path.join(outputDir, filename);

try {
fs.writeFileSync(targetFile, segment.content, 'utf-8');
} catch (e) {
fail(`Failed writing ${filename}, aborting. Wrote ${i + 1} segments.`, e);
}

const range = 5;

if ((0 <= i && i < range) || (n - range <= i && i <= n)) {
log(`Wrote segment ${targetFile}`);
} else {
Expand Down Expand Up @@ -123,9 +128,11 @@ function log (m) {
function fail (m, e) {
if (!program.silent) {
console.log(m);

if (e) {
console.log(`Exception: ${e.stack}`);
}
}

process.exit(1);
}
1 change: 1 addition & 0 deletions lib/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function ParserError (message, error) {
this.message = message;
this.error = error;
}

ParserError.prototype = Object.create(Error.prototype);

const TIMESTAMP_REGEXP = /([0-9]{1,2})?:?([0-9]{2}):([0-9]{2}\.[0-9]{3})/;
Expand Down
1 change: 1 addition & 0 deletions lib/segmenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function alignToSegmentLength (n, segmentLength) {
}

const debugging = false;

function debug (m) {
if (debugging) {
console.log(m);
Expand Down
Loading

0 comments on commit 071bd45

Please sign in to comment.