mirror of
https://github.com/snobu/destreamer.git
synced 2026-02-20 05:19:43 +00:00
removed dependancy from argv in our test
This commit is contained in:
@@ -1,10 +1,9 @@
|
|||||||
import { CLI_ERROR, ERROR_CODE } from './Errors';
|
import { CLI_ERROR } from './Errors';
|
||||||
import { makeOutDir } from './Utils';
|
import { makeOutDir } from './Utils';
|
||||||
import { logger } from './Logger';
|
import { logger } from './Logger';
|
||||||
import { templateElements } from './Types';
|
import { templateElements } from './Types';
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import readlineSync from 'readline-sync';
|
|
||||||
import sanitize from 'sanitize-filename';
|
import sanitize from 'sanitize-filename';
|
||||||
import yargs from 'yargs';
|
import yargs from 'yargs';
|
||||||
|
|
||||||
@@ -198,14 +197,3 @@ function isOutputTemplateValid(argv: any): boolean {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export function promptUser(choices: Array<string>): number {
|
|
||||||
const index: number = readlineSync.keyInSelect(choices, 'Which resolution/format do you prefer?');
|
|
||||||
|
|
||||||
if (index === -1) {
|
|
||||||
process.exit(ERROR_CODE.CANCELLED_USER_INPUT);
|
|
||||||
}
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
|
|||||||
12
src/Utils.ts
12
src/Utils.ts
@@ -6,6 +6,7 @@ import { StreamSession, VideoUrl } from './Types';
|
|||||||
import { AxiosResponse } from 'axios';
|
import { AxiosResponse } from 'axios';
|
||||||
import { execSync } from 'child_process';
|
import { execSync } from 'child_process';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
|
import readlineSync from 'readline-sync';
|
||||||
|
|
||||||
|
|
||||||
const streamUrlRegex = new RegExp(/https?:\/\/web\.microsoftstream\.com.*/);
|
const streamUrlRegex = new RegExp(/https?:\/\/web\.microsoftstream\.com.*/);
|
||||||
@@ -237,3 +238,14 @@ export function ffmpegTimemarkToChunk(timemark: string): number {
|
|||||||
|
|
||||||
return (hrs * 60 * 60) + (mins * 60) + secs;
|
return (hrs * 60 * 60) + (mins * 60) + secs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export function promptUser(choices: Array<string>): number {
|
||||||
|
const index: number = readlineSync.keyInSelect(choices, 'Which resolution/format do you prefer?');
|
||||||
|
|
||||||
|
if (index === -1) {
|
||||||
|
process.exit(ERROR_CODE.CANCELLED_USER_INPUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
return index;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { StreamApiClient } from './ApiClient';
|
import { StreamApiClient } from './ApiClient';
|
||||||
import { promptUser } from './CommandLineParser';
|
import { promptUser } from './Utils';
|
||||||
import { logger } from './Logger';
|
import { logger } from './Logger';
|
||||||
import { Video, StreamSession, VideoUrl } from './Types';
|
import { Video, StreamSession, VideoUrl } from './Types';
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { StreamSession, VideoUrl } from './Types';
|
|||||||
|
|
||||||
|
|
||||||
// we cannot test groups parsing as that requires an actual session
|
// we cannot test groups parsing as that requires an actual session
|
||||||
|
// TODO: add SharePoint urls
|
||||||
describe('Destreamer parsing', () => {
|
describe('Destreamer parsing', () => {
|
||||||
it('Input file to arrays of guids', async () => {
|
it('Input file to arrays of guids', async () => {
|
||||||
const testSession: StreamSession = {
|
const testSession: StreamSession = {
|
||||||
|
|||||||
Reference in New Issue
Block a user